Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="data"></param>
        private void PrepareSound(BannerData data)
        {
            _player = new WasapiOut();
            var task = new Task(() =>
            {
                using var waveStream = new CachedSoundWaveStream(data.SoundFile);
                _player.Init(waveStream);
                _player.Play();
                while (_player.PlaybackState == PlaybackState.Playing)
                {
                    Thread.Sleep(500);
                }
            });

            task.Start();
        }
Ejemplo n.º 2
0
 public void NotifyDefaultChanged(MMDevice audioDevice)
 {
     if (audioDevice.DataFlow != DataFlow.Render)
     {
         return;
     }
     Task.Factory.StartNew(() =>
     {
         using var output     = new WasapiOut(audioDevice, AudioClientShareMode.Shared, true, 10);
         using var waveStream = new CachedSoundWaveStream(Configuration.CustomSound);
         output.Init(waveStream);
         output.Play();
         while (output.PlaybackState == PlaybackState.Playing)
         {
             Thread.Sleep(500);
         }
     });
 }
Ejemplo n.º 3
0
        public void NotifyDefaultChanged(IAudioDevice audioDevice)
        {
            if (audioDevice.Type != AudioDeviceType.Playback)
            {
                return;
            }
            var task = new Task(() =>
            {
                var device = _deviceEnumerator.GetDevice(audioDevice.Id);
                using (var output = new WasapiOut(device, AudioClientShareMode.Shared, true, 10))
                    using (var waveStream = new CachedSoundWaveStream(Configuration.CustomSound))
                    {
                        output.Init(waveStream);
                        output.Play();
                        while (output.PlaybackState == PlaybackState.Playing)
                        {
                            Thread.Sleep(500);
                        }
                    }
            });

            task.Start();
        }