예제 #1
0
 private void GetNewSoundOut()
 {
     _soundOut.Stop();
     _soundOut.WaitForStopped();
     GetOutputSound();
     _systemSimpleAudioVolume = GetSimpleAudioVolume();
     _soundOut.Volume         = AlarmVolume;
 }
 public void Play(MusicFile file)
 {
     CleanupPlayback();
     _waveSource = CodecFactory.Instance.GetCodec(file.FullName);
     _soundOut   = new WasapiOut();
     _soundOut.Initialize(_waveSource);
     _soundOut.Play();
     _soundOut.WaitForStopped();
 }
예제 #3
0
 public void Stop()
 {
     if (_soundOut != null)
     {
         for (int i = 0; i < 12; i++)            //workaround for buffer not being flushed and what's left in the buffer
                                                 //plays when you restart. This assumes first 10ms of track are silent and
                                                 //plays it 12 times (guess based on latency=100)
         {
             _soundOut.WaveSource.Position = 0;
             _soundOut.WaitForStopped(10);
         }
         _soundOut.Stop();
     }
 }
예제 #4
0
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            _soundOut.Stop();
            _soundOut.WaitForStopped();
            _soundOut.Dispose();

            _mixer.Dispose();

            _disposed = true;
        }