示例#1
0
 public void Pausar()
 {
     if (_salida != null)
     {
         _salida.Pause();
     }
 }
示例#2
0
        public bool Pause()
        {
            if (_soundOut != null)
            {
                if (_soundOut.PlaybackState != CSCore.SoundOut.PlaybackState.Paused)
                {
                    _soundOut.Pause();
                    return(true);
                }
            }

            return(false);
        }
示例#3
0
        public async Task TogglePlayPause()
        {
            if (IsLoading || _soundSource == null || _soundOut == null)
            {
                return;
            }

            if (_fadingService.IsFading)
            {
                _fadingService.Cancel();
            }

            if (_soundOut.PlaybackState == PlaybackState.Playing)
            {
                _playTimeStopwatch.Stop();
                _isPausing = true;
                CurrentStateChanged();
                await _fadingService.FadeOut(_soundOut, Volume);

                _soundOut?.Pause();
                _isPausing = false;
                CurrentStateChanged();
            }
            else
            {
                _playTimeStopwatch.Start();
                _soundOut?.Play();
                CurrentStateChanged();
                await _fadingService.FadeIn(_soundOut, Volume);
            }
        }
        public void Pause()
        {
            _soundOut.Pause();

            this.PlayState = PlayState.Paused;
            Paused?.Invoke();
        }
示例#5
0
        private void StopTheAlarm(ref VolumeCheckArgs vca, bool disableSound, bool disableOverlay)
        {
            if (vca.resetOverlay && vca.resetSound)
            {
                vca.meterColor = VOLUME_OK;
            }

            if (disableSound)
            {
                _soundOut.Pause();

                if (_timerAlarmDelay.IsEnabled)
                {
                    _timerAlarmDelay.Stop();
                }
            }

            if (disableOverlay)
            {
                if (_timerOverlayShow.IsEnabled)
                {
                    _timerOverlayShow.Stop();
                }
                if (_overlayWorking)
                {
                    _overlayWorking = false;
                }
            }
        }
示例#6
0
 private void btn_pause_Click(object sender, EventArgs e)
 {
     if (soundOut != null)
     {
         soundOut.Pause();
     }
 }
示例#7
0
 public void Pause()
 {
     if (_soundOut != null)
     {
         _soundOut.Pause();
     }
 }
示例#8
0
 public override void Pause()
 {
     lock (locker)
     {
         soundOut.Pause();
     }
 }
示例#9
0
 /// <summary>
 /// 暂停
 /// </summary>
 public void Pause()
 {
     if (_soundOut.PlaybackState == PlaybackState.Playing)
     {
         _soundOut.Pause(); //暂停播放
     }
 }
示例#10
0
 public void Pause()
 {
     if (mSoundOut != null)
     {
         mSoundOut.Pause();
     }
 }
 public override void Pause()
 {
     if (_soundOut != null)
     {
         _soundOut.Pause();
     }
 }
示例#12
0
 public void Pausar()
 {
     if (_output != null)
     {
         _output.Pause();
     }
 }
示例#13
0
 public void PauseScore()
 {
     IsPlaying = false;
     if (SoundOut != null)
     {
         SoundOut.Pause();
     }
 }
示例#14
0
 public void Pause()
 {
     if (State == SoundState.Playing)
     {
         _soundOut.Pause();
     }
     OnSoundStateChanged(new SoundStateChangedEventArgs(SoundState.Paused));
 }
示例#15
0
 private void GameBoy_PauseRequested()
 {
     if ((_soundOut != null) &&
         (_soundOut.PlaybackState == PlaybackState.Playing))
     {
         _soundOut.Pause();
     }
 }
示例#16
0
 //Pause
 private void button_pause_Click(object sender, EventArgs e)
 {
     if (db > 0)
     {
         device.Pause();
         paused = 1;
     }
 }
示例#17
0
 public void Pause()
 {
     if (_soundOut != null)
     {
         _soundOut.Pause();
     }
     PlaybackChanged(null, null);
 }
示例#18
0
 public void Pause()
 {
     CheckForCreated();
     if (IsPlaying)
     {
         _soundOut.Pause();
     }
 }
示例#19
0
        public async void TogglePlayPause()
        {
            try
            {
                if (IsLoading)
                {
                    _playAfterLoading = !_playAfterLoading;
                    return;
                }

                if (CurrentTrack == null)
                {
                    return;
                }
                if (_fader != null && _fader.IsFading)
                {
                    _fader.CancelFading();
                    _fader.WaitForCancel();
                }
                if (_soundOut.PlaybackState == PlaybackState.Playing)
                {
                    if (_crossfade != null && _crossfade.IsCrossfading)
                    {
                        _crossfade.CancelFading();
                    }
                    _isfadingout = true;
                    CurrentStateChanged();
                    if (_fader != null)
                    {
                        await _fader.FadeOut(_soundOut, Volume);
                    }
                    _soundOut.Pause();
                    CurrentStateChanged();
                    _isfadingout = false;
                }
                else
                {
                    try
                    {
                        _soundOut.Play();
                    }
                    catch (Exception)
                    {
                        return;
                    }
                    CurrentStateChanged();
                    if (_fader != null)
                    {
                        await _fader.FadeIn(_soundOut, Volume);
                    }
                }
            }
            catch (ObjectDisposedException)
            {
                //Nearly everywhere in this code block can an ObjectDisposedException get thrown. We can safely ignore that
            }
        }
示例#20
0
 void Pause()
 {
     if (soundOut.PlaybackState == PlaybackState.Playing)
     {
         soundOut.Pause();
         timer_ctime.Enabled = false;
         btn_Play.Visible    = true;
         btn_pause.Visible   = false;
     }
 }
示例#21
0
        public bool Pause()
        {
            if (CurrentPlaybackState == PlaybackState.Playing)
            {
                _soundOut.Pause();
                return(true);
            }

            return(false);
        }
示例#22
0
 public void Pause()
 {
     if (state != SOUNDSTATE.PAUSED && state != SOUNDSTATE.STOPPED && state != SOUNDSTATE.FORMING && soundOut != null)
     {
         soundOut.Pause();
         state = SOUNDSTATE.PAUSED;
     }
     else if (state == SOUNDSTATE.PAUSED && state != SOUNDSTATE.STOPPED && state != SOUNDSTATE.FORMING && soundOut != null)
     {
         Play();
     }
 }
示例#23
0
 public void TooglePlayPause()
 {
     if (_soundOut?.PlaybackState == PlaybackState.Playing)
     {
         _soundOut?.Pause();
     }
     else
     {
         _soundOut?.Play();
     }
     CurrentStateChanged();
 }
示例#24
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (soundOut.PlaybackState == PlaybackState.Paused || soundOut.PlaybackState == PlaybackState.Stopped)
     {
         Play.Text = "Pause";
         soundOut.Play();
     }
     else
     {
         Play.Text = "Play";
         soundOut.Pause();
     }
 }
示例#25
0
        public void ThrowsInvalidCallerThread()
        {
            Exception exception = null;

            using (var source = new NotificationSource(GetLoopingWaveSource().ToSampleSource()))
            {
                using (var waitHandle = new ManualResetEvent(false))
                {
                    _soundOut.Initialize(source.ToWaveSource());
                    //the play method sometimes won't cause an InvalidOperationException
                    //for example the waveout class will read from the source which fires up the BlockRead event BUT not on the playbackthread.
                    _soundOut.Play();
                    source.BlockRead += (s, e) =>
                    {
                        try
                        {
                            _soundOut.Pause(); //hopefully throws InvalidOperationException
                        }
                        catch (InvalidOperationException ex)
                        {
                            exception = ex;
                        }
                        finally
                        {
// ReSharper disable once AccessToDisposedClosure
                            waitHandle.Set();
                        }
                    };
                    waitHandle.WaitOne();

                    _soundOut.Stop();
                }
            }
            if (exception != null)
            {
                throw exception;
            }
        }
示例#26
0
 private void mainWindow_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Space)
     {
         if (waveOut.PlaybackState != PlaybackState.Playing)
         {
             waveOut.Play();
         }
         else
         {
             waveOut.Pause();
         }
     }
 }
示例#27
0
        public void Pause()
        {
            var resourceItem = Items[SelectedIndex];

            if (PlaybackState == PlaybackState.Playing)
            {
                _soundOut.Pause();
                PlayPaused(resourceItem);
            }
            else if (PlaybackState == PlaybackState.Paused)
            {
                _soundOut.Play();
                PlayContinue(resourceItem);
            }
        }
示例#28
0
        private void CanHandleEOFTestInternal(ISoundOut soundOut, IWaveSource source)
        {
            int sourceLength = (int)source.GetLength().TotalMilliseconds;

            Debug.WriteLine(soundOut.GetType().FullName);
            for (int i = 0; i < BasicIterationCount; i++)
            {
                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");

                soundOut.Stop();
                source.Position = 0;

                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");

                soundOut.Pause();
                soundOut.Resume();

                Thread.Sleep(10);

                soundOut.Stop();
                source.Position = 0;

                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep(sourceLength + 1000);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");
                Assert.AreEqual(PlaybackState.Stopped, soundOut.PlaybackState);

                source.Position = 0;
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");
            }
        }
示例#29
0
        private void CanHandleEOFTestInternal(ISoundOut soundOut, IWaveSource source)
        {
            int sourceLength = (int)source.GetLength().TotalMilliseconds;

            for (int i = 0; i < basic_iteration_count; i++)
            {
                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");

                soundOut.Stop();
                source.Position = 0;

                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");

                soundOut.Pause();
                soundOut.Resume();

                Thread.Sleep(10);

                soundOut.Stop();
                source.Position = 0;

                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");

                source.Position = 0;
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");
            }
        }
示例#30
0
        //***********************************************************************************************************************************************************************************************************

        /// <summary>
        /// Pause a record
        /// </summary>
        public void PauseRecord()
        {
            try
            {
                if (RecordState == RecordStates.RECORDING)
                {
                    _silenceOut.Pause();
                    RecordState = RecordStates.PAUSED;
                    _logHandle.Report(new LogEventInfo("Record (\"" + TrackInfo?.TrackName + "\") paused."));
                    WasRecordPaused = true;

                    double recordLength_s = (_wavWriterPositionBytes / _wavWriterFormat.BytesPerSecond);
                    _recordPauseTimes_s.Add(recordLength_s);
                }
            }
            catch (Exception ex)
            {
                _logHandle.Report(new LogEventError("Error while pausing record: " + ex.Message));
            }
        }
示例#31
0
        private void PlayPauseResumeBehaviourTestInternal(ISoundOut soundOut, IWaveSource source)
        {
            for (int i = 0; i < BasicIterationCount; i++)
            {
                soundOut.Initialize(source);
                //--

                Assert.AreEqual(PlaybackState.Stopped, soundOut.PlaybackState);

                soundOut.Play();
                Assert.AreEqual(PlaybackState.Playing, soundOut.PlaybackState);

                Thread.Sleep(50);

                soundOut.Play();
                Assert.AreEqual(PlaybackState.Playing, soundOut.PlaybackState);

                soundOut.Pause();
                Assert.AreEqual(PlaybackState.Paused, soundOut.PlaybackState);

                soundOut.Pause();
                Assert.AreEqual(PlaybackState.Paused, soundOut.PlaybackState);

                soundOut.Play();
                Assert.AreEqual(PlaybackState.Playing, soundOut.PlaybackState);

                soundOut.Pause();
                Assert.AreEqual(PlaybackState.Paused, soundOut.PlaybackState);

                soundOut.Resume();
                Assert.AreEqual(PlaybackState.Playing, soundOut.PlaybackState);
                //--
                Thread.Sleep(250);
                //--
                soundOut.Play();
                Assert.AreEqual(PlaybackState.Playing, soundOut.PlaybackState);

                Thread.Sleep(50);

                soundOut.Play();
                Assert.AreEqual(PlaybackState.Playing, soundOut.PlaybackState);

                soundOut.Pause();
                Assert.AreEqual(PlaybackState.Paused, soundOut.PlaybackState);
                soundOut.Pause();
                Assert.AreEqual(PlaybackState.Paused, soundOut.PlaybackState);

                soundOut.Play();
                Assert.AreEqual(PlaybackState.Playing, soundOut.PlaybackState);

                soundOut.Pause();
                Assert.AreEqual(PlaybackState.Paused, soundOut.PlaybackState);

                soundOut.Resume();
                Assert.AreEqual(PlaybackState.Playing, soundOut.PlaybackState);
                //--

                soundOut.Stop();
                Assert.AreEqual(PlaybackState.Stopped, soundOut.PlaybackState);

                soundOut.Play();
                Assert.AreEqual(PlaybackState.Playing, soundOut.PlaybackState);

                Thread.Sleep(10);

                soundOut.Stop();
                Assert.AreEqual(PlaybackState.Stopped, soundOut.PlaybackState);

                soundOut.Play();
                Assert.AreEqual(PlaybackState.Playing, soundOut.PlaybackState);

                soundOut.Pause();
                Assert.AreEqual(PlaybackState.Paused, soundOut.PlaybackState);

                Thread.Sleep(50);

                //--
                soundOut.Stop();
                Assert.AreEqual(PlaybackState.Stopped, soundOut.PlaybackState);
                source.Position = 0;
            }
        }
示例#32
0
        private void CanHandleEOFTestInternal(ISoundOut soundOut, IWaveSource source)
        {
            int sourceLength = (int)source.GetLength().TotalMilliseconds;
            Debug.WriteLine(soundOut.GetType().FullName);
            for (int i = 0; i < BasicIterationCount; i++)
            {
                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");

                soundOut.Stop();
                source.Position = 0;

                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");

                soundOut.Pause();
                soundOut.Resume();

                Thread.Sleep(10);

                soundOut.Stop();
                source.Position = 0;

                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep(sourceLength + 1000);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");
                Assert.AreEqual(PlaybackState.Stopped, soundOut.PlaybackState);

                source.Position = 0;
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");
            }
        }
示例#33
0
        private void CanHandleEOFTestInternal(ISoundOut soundOut, IWaveSource source)
        {
            int sourceLength = (int)source.GetLength().TotalMilliseconds;
            for (int i = 0; i < basic_iteration_count; i++)
            {
                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");

                soundOut.Stop();
                source.Position = 0;

                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");

                soundOut.Pause();
                soundOut.Resume();

                Thread.Sleep(10);

                soundOut.Stop();
                source.Position = 0;

                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");

                source.Position = 0;
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");
            }
        }