public Song.Clip GetNextClip() { Song.Clip clip = null; if (this._clipIndex == -1) { // Set the clip index to 0 this._clipIndex = 0; } else if (this._clipIndex < this._song.HintClipList.Count) { // Increment the clip index this._clipIndex++; } if (_clipIndex >= 0 && _clipIndex < this._song.HintClipList.Count) { // Get the clip clip = this._song.HintClipList[this._clipIndex]; System.Diagnostics.Debug.WriteLine("------------Got New Clip-------------------"); System.Diagnostics.Debug.WriteLine(string.Format("Clip: {0}", clip)); } return(clip); }
private void playClip(Song.Clip clip) { TimeSpan tFull = TimeSpan.FromMilliseconds((clip.Duration * 1000)); TimeSpan tPlayedAlready = amountOfClipPlayed; TimeSpan timeLeft = tFull - tPlayedAlready; if (stopTimer == null) { // Create the timer stopTimer = new System.Threading.Timer(TimerElapsed, null, (long)timeLeft.TotalMilliseconds, Timeout.Infinite); } else { // Change the timer stopTimer.Change((long)(timeLeft.TotalMilliseconds), Timeout.Infinite); } currentClipPlayStartTime = DateTime.Now; // Determine the position to start playing from double currentPosition = clip.StartTime.TotalSeconds + amountOfClipPlayed.TotalMilliseconds / 1000; // Play the clip this.axWindowsMediaPlayer.uiMode = "none"; this.axWindowsMediaPlayer.URL = Path.Combine(theGame.SongFile.songPath, clip.Song.FileName); this.axWindowsMediaPlayer.Ctlcontrols.currentPosition = currentPosition; MediaPlayerPlay(); // Set the current state to playing this.btnCurrentPlayButtonState = buttonPlayState.STATE_PLAYING; updateControls(); }
private void btnSolve_Click(object sender, EventArgs e) { playingSolutionClip = true; if (btnAnswerState == buttonAnswerState.STATE_NONE) { btnAnswerState = buttonAnswerState.STATE_PLAYING_ANSWER_ONLY; Song.Clip solutionClip = theGame.CurrentGame.Song.SolutionClip; playClip(solutionClip); } else if (btnAnswerState == buttonAnswerState.STATE_PLAYING_ANSWER_ONLY) { btnAnswerState = buttonAnswerState.STATE_PLAYING_FULL_SONG; playFullSong(); } else if (btnAnswerState == buttonAnswerState.STATE_PLAYING_FULL_SONG) { btnAnswerState = buttonAnswerState.STATE_PLAYING_ANSWER_ONLY; Song.Clip solutionClip = theGame.CurrentGame.Song.SolutionClip; playClip(solutionClip); } updateControls(); this.tbSongInfo.Text = string.Format("Song: {0}...", theGame.CurrentGame.Song.Name); }
private void btnPlayAllClips_Click(object sender, EventArgs e) { if (this.InvokeRequired) { this.Invoke(new MethodInvoker(() => { btnPlayAllClips_Click(sender, e); })); return; } switch (btnCurrentPlayButtonState) { case buttonPlayState.STATE_NONE: // Get the next clip currentClip = theGame.CurrentGame.GetNextClip(); if (currentClip != null) { amountOfClipPlayed = TimeSpan.FromSeconds(0.0f); // Update the controls updateControls(); this.tbSongInfo.Text = string.Format("Playing Song #{0}, Clip {1}/{2} [{3}s]", theGame.SongIndex + 1, theGame.CurrentGame.ClipIndex + 1, theGame.CurrentGame.Song.HintClipList.Count, currentClip.Duration); // Play the next clip if (currentClip != null) { playClip(currentClip); } } break; case buttonPlayState.STATE_PAUSED: // Resume play playClip(currentClip); break; case buttonPlayState.STATE_PLAYING: // Stop the timer stopTimer.Change(Timeout.Infinite, Timeout.Infinite); // Update the state this.btnCurrentPlayButtonState = buttonPlayState.STATE_PAUSED; // Update the amount of clip played DateTime d1 = currentClipPlayStartTime; DateTime d2 = DateTime.Now; amountOfClipPlayed += (d2 - d1); // Pause play MediaPlayerPause(); // Update the controls updateControls(); break; } }
public Song.Clip GetPrevClip() { Song.Clip clip = null; if (this._clipIndex >= 0) { // Increment the clip index this._clipIndex--; } if (_clipIndex >= 0) { // Get the next clip clip = this._song.HintClipList[this._clipIndex]; System.Diagnostics.Debug.WriteLine("------------Got New Clip-------------------"); System.Diagnostics.Debug.WriteLine(string.Format("Clip: {0}", clip)); } return(clip); }
private void btnNextSong_Click(object sender, EventArgs e) { // Stop any song that might be playing currently MediaPlayerStop(); if (stopTimer != null) { // Disable the timer stopTimer.Change(Timeout.Infinite, Timeout.Infinite); } // Get the next song theGame.GetNextSingleGame(); // Update the controls this.axWindowsMediaPlayer.uiMode = "none"; this.btnCurrentPlayButtonState = buttonPlayState.STATE_NONE; this.btnAnswerState = buttonAnswerState.STATE_NONE; playingSolutionClip = false; currentClip = null; updateControls(); this.tbSongInfo.Text = string.Format("Loaded Song {0}/{1}", theGame.SongIndex + 1, theGame.SongFile.listOfSongs.Count); }