Esempio n. 1
0
        public void PlayAlarm(bool playAlarm = true)
        {
            if (_defaultDeviceChanged)
            {
                return;
            }
            _timerAlarmDelayArgs             = new TimerDelayArgs(DateTime.Now);
            _timerAlarmDelayArgs.alarmActive = true;
            OnUpdateTimerAlarmDelay(this, _timerAlarmDelayArgs);
            _isSoundAlertPlaying = true;
            if (!playAlarm)
            {
                return;
            }

            if (_soundOut.GetType() == typeof(WasapiOut))
            {
                if ((_soundOut as WasapiOut).Device.DeviceState != DeviceState.Active)
                {
                    GetNewSoundOut();
                }
            }

            if (_soundOut.PlaybackState == PlaybackState.Paused)
            {
                _soundOut.Resume();
            }
            else
            {
                _soundOut.Play();
            }
        }
Esempio n. 2
0
 public virtual void OnTestInitialize()
 {
     _soundOut = CreateSoundOut();
     if (_soundOut == null)
     {
         throw new Exception("No valid soundout.");
     }
     Debug.WriteLine(_soundOut.GetType().FullName);
 }
Esempio n. 3
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");
            }
        }
Esempio n. 4
0
        public void SoundOutBehaviour()
        {
            using (var source = new DisposableSource(GetLoopingWaveSource()))
            {
                Assert.AreEqual(PlaybackState.Stopped, _soundOut.PlaybackState);
                _soundOut.Initialize(source);
                Assert.AreEqual(PlaybackState.Stopped, _soundOut.PlaybackState);
                _soundOut.Play();
                Assert.AreEqual(PlaybackState.Playing, _soundOut.PlaybackState);
                Thread.Sleep(20);
                _soundOut.Pause();
                Assert.AreEqual(PlaybackState.Paused, _soundOut.PlaybackState);
                Thread.Sleep(20);
                _soundOut.Resume();
                Assert.AreEqual(PlaybackState.Playing, _soundOut.PlaybackState);
                Thread.Sleep(20);
                _soundOut.Dispose();

                Assert.IsFalse(source.IsDisposed, "{0} disposed source.", _soundOut.GetType().FullName);
            }
        }
Esempio n. 5
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");
            }
        }
Esempio n. 6
0
 public virtual void OnTestInitialize()
 {
     _soundOut = CreateSoundOut();
     if (_soundOut == null)
         throw new Exception("No valid soundout.");
     Debug.WriteLine(_soundOut.GetType().FullName);
 }