public void PlaySound()
        {
            if (_waveOut == null)
            {
                SetupSound();
            }

            _waveOut.Volume = 1.0F;
            _waveOut?.Play();
            _waveOut?.Pause();
            _waveOut?.Play();
        }
Beispiel #2
0
 public void Pause()
 {
     if (IsPlaying && !IsPaused)
     {
         player.pause();
         IsPaused = true;
         wavePlayer?.Pause();
     }
 }
Beispiel #3
0
        public void Pause()
        {
            if (reader2 == null)
            {
                return;
            }

            if (wout?.PlaybackState != PlaybackState.Playing)
            {
                return;
            }

            wout?.Pause();
        }
Beispiel #4
0
 public void Pause()
 {
     if (waveOut.PlaybackState != PlaybackState.Stopped)
     {
         if (waveOut.PlaybackState == PlaybackState.Paused)
         {
             waveOut?.Play();
         }
         else
         {
             waveOut?.Pause();
             OnPause?.Invoke(new GenericEventArgs());
         }
     }
 }
Beispiel #5
0
 public void PlayPauseStream()
 {
     if (waveOut != null)
     {
         if (_streamState == StreamState.Playing)
         {
             waveOut?.Pause();
             _streamState = StreamState.Paused;
         }
         else if (_streamState == StreamState.Paused)
         {
             waveOut?.Play();
             _streamState = StreamState.Playing;
         }
     }
 }
Beispiel #6
0
        /// <summary>
        /// If playing, pause. If paused, play.
        /// </summary>
        /// <returns>bool representing state: true if paused, false if playing.</returns>
        public bool Pause()
        {
            bool result = true; // assume it is paused

            if (waveOut != null)
            {
                if (waveOut.PlaybackState == PlaybackState.Playing)
                {
                    waveOut.Pause();
                    result = true;
                    //playbackTimer.Enabled = false;
                }
                else if (waveOut.PlaybackState == PlaybackState.Paused)
                {
                    waveOut.Play();
                    result = false;
                    //playbackTimer.Enabled = true;
                }
            }
            return(result);
        }
 private void button_pause_Click(object sender, EventArgs e)
 {
     try
     {
         if (!isPaused)
         {
             wavePlayer.Pause();
             isPaused = true;
             button_pause.BackgroundImage   = Properties.Resources.play;
             pictureBox_visualisation.Image = Properties.Resources.ColorImage;
         }
         else
         {
             wavePlayer.Play();
             isPaused = false;
             button_pause.BackgroundImage   = Properties.Resources.pause;
             pictureBox_visualisation.Image = Properties.Resources.PlayingSound;
         }
     }
     catch (NullReferenceException)
     {
         MessageBox.Show("Song is not playing at the moment");
     }
 }
Beispiel #8
0
 public static void PauseAudioFile()
 {
     waveOutDevice?.Pause();
     MusicViewModel.GetInstance().IsPlaying = false;
 }
Beispiel #9
0
 public void Pause()
 {
     playbackState = StreamingPlaybackState.Buffering;
     waveOut.Pause();
     _log.Debug(String.Format("Paused to buffer, waveOut.PlaybackState={0}", waveOut.PlaybackState));
 }
Beispiel #10
0
 public void Pause()
 {
     _soundPlayer.Pause();
 }
Beispiel #11
0
 private void PauseWithoutNotify()
 {
     _device?.Pause();
 }
Beispiel #12
0
 public void Pause()
 {
     _wavePlayer?.Pause();
 }
 public void Pause()
 {
     _device.Pause();
     PlayerStatus = PlayerStatus.Paused;
 }
Beispiel #14
0
 private void Pause()
 {
     playbackState = StreamingPlaybackState.Buffering;
     waveOut.Pause();
     Debug.WriteLine(String.Format("Paused to buffer, waveOut.PlaybackState={0}", waveOut.PlaybackState));
 }
        /// <summary>
        /// Method that plays whatever the current song is
        /// </summary>
        private void playSong()
        {
            skipThis = false;
            Stream stream = Subsonic.StreamSong(currentSong.id);

            // Try to move this filling of memory stream into the background...
            Stream ms = new MemoryStream();
            byte[] buffer = new byte[32768];
            int read;
            while ((read = stream.Read(buffer, 0, buffer.Length)) > 0)
            {
                playerThread.ReportProgress(50);

                ms.Write(buffer, 0, read);
            }

            ms.Position = 0;
            Mp3FileReader mp3Reader = new Mp3FileReader(ms);
            WaveStream blockAlignedStream =
                new BlockAlignReductionStream(
                    WaveFormatConversionStream.CreatePcmStream(mp3Reader));
            WaveOut waveOut;
            waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback());
            waveOut.Init(blockAlignedStream);
            waveOut.Play();
            playState = PlaybackState.Playing;
            bool songEnd = false;
            while (playState != PlaybackState.Stopped && !songEnd && !skipThis)
            {
                if (waveOut.PlaybackState == PlaybackState.Stopped)
                    songEnd = true;
                else
                {
                    switch (playState)
                    {
                        case PlaybackState.Paused:
                            waveOut.Pause();
                            break;
                        case PlaybackState.Playing:
                            if (waveOut.PlaybackState != PlaybackState.Playing)
                                waveOut.Play();
                            else
                            {
                                int progress = (int)(100.0 * mp3Reader.CurrentTime.TotalSeconds / mp3Reader.TotalTime.TotalSeconds);
                                playerThread.ReportProgress(progress);
                                Thread.Sleep(100);
                            }
                            break;
                        default:
                            break;
                    }
                }
            }
            //if (playState == PlaybackState.Stopped)
            waveOut.Stop();
            //waveOut.Dispose();
        }
Beispiel #16
0
 public void Pausar()
 {
     reproductorWaveOut.Pause();
 }
Beispiel #17
0
        public override void Stop()
        {
            base.Stop();

            _wasapiOut.Pause();
        }
Beispiel #18
0
 public void Pause()
 {
     wavePlayer.Pause();
 }
Beispiel #19
0
 public void Pause()
 {
     wavePlayer.Pause();
     _IsPlaying = false;
 }
Beispiel #20
0
 public void Pause()
 {
     playbackDevice?.Pause();
 }
Beispiel #21
0
 public void Pause()
 {
     _userStopped = true;
     _myWaveOut.Pause();
 }
Beispiel #22
0
 public void Pause()
 {
     _wavePlayer.Pause();
     Status = PlaybackStatus.Paused;
 }
Beispiel #23
0
 //Pauses the current song.
 private void btnPause_Click(object sender, EventArgs e)
 {
     waveOutDevice.Pause();
     paused = true;
 }
Beispiel #24
0
 private void button6_Click(object sender, EventArgs e)  //pause
 {
     waveOutDevice.Pause();
 }
Beispiel #25
0
 private void Pause()
 {
     _playbackState = StreamingPlaybackState.Buffering;
     _waveOut.Pause();
     Debug.WriteLine("Paused to buffer, waveOut.PlaybackState={0}", _waveOut.PlaybackState);
 }
Beispiel #26
0
 public void PauseSound()
 {
     _waveOut?.Pause();
 }
Beispiel #27
0
 public void Pause()
 {
     output.Pause();
     PlaybackStateChanged?.Invoke(this, new EventArgs());
 }
Beispiel #28
0
 public void Pause()
 {
     player.Pause();
 }
Beispiel #29
0
 public void Pause()
 {
     waveOut.Pause();
 }
Beispiel #30
0
 private void PauseAction()
 {
     _device?.Pause();
 }
Beispiel #31
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     if (player != null)
     {
         if (radio != null || radio.playState == WMPPlayState.wmppsPlaying)
         {
             playradio.Content = "Play";
             radio.controls.pause();
         }
     }
     if (player != null)
     {
         if (player.PlaybackState == NAudio.Wave.PlaybackState.Playing)
         {
             play.Content = "Play";
             player.Pause();
         }
         else if (player.PlaybackState == NAudio.Wave.PlaybackState.Paused || player.PlaybackState == NAudio.Wave.PlaybackState.Stopped)
         {
             play.Content = "Pause";
             player.Play();
         }
     }
 }