AudioPlayerApp.AudioPlayer.Pause C# (CSharp) Method

Pause() public method

Pauses the sound.
public Pause ( ) : void
return void
        public void Pause()
        {
            if (State == AudioPlayerState.Playing)
            {
                clock.Stop();
                State = AudioPlayerState.Paused;
                playEvent.Reset();
            }
        }

Usage Example

Example #1
0
 private void PlayPauseButton_Click(object sender, RoutedEventArgs e)
 {
     lock (lockAudio)
     {
         if (audioPlayer != null)
         {
             if (audioPlayer.State == AudioPlayerState.Playing)
             {
                 audioPlayer.Pause();
             }
             else
             {
                 audioPlayer.Play();
             }
         }
     }
 }