Exemplo n.º 1
0
        private void TimerElapsed(object obj)
        {
            MediaPlayerStop();
            stopTimer.Change(Timeout.Infinite, Timeout.Infinite);

            btnCurrentPlayButtonState = buttonPlayState.STATE_NONE;
            amountOfClipPlayed        = TimeSpan.FromMilliseconds(0.0f);
            updateControls();

            if (!playingSolutionClip)
            {
                if (!theGame.CurrentGame.IsLastClip())
                {
                    if (theGame.SongFile.pauseLength > 0)
                    {
                        Thread.Sleep(theGame.SongFile.pauseLength);
                    }

                    this.btnPlayAllClips_Click(this, null);
                }
                else
                {
                    theGame.CurrentGame.ResetClipIndex();
                    updateControlsPostClipPlay();
                }
            }
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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;
            }
        }
Exemplo n.º 4
0
        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);
        }