public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (value is string)
     {
         MMDevice item = AudioDevices.FirstOrDefault(q => (string.Compare(q.ToString(), value.ToString(), true) == 0));
         return(item);
     }
     else
     {
         return(base.ConvertFrom(context, culture, value));
     }
 }
Ejemplo n.º 2
0
        public WaveOutAudioPlayer(IWaveProvider waveProvider) : base(waveProvider)
        {
            audioDevices = new ObservableCollection <string>();

            for (int i = 0; i < WaveOut.DeviceCount; i++)
            {
                var caps = WaveOut.GetCapabilities(i);
                audioDevices.Add(caps.ProductName);
            }

            SelectedAudioDevice = AudioDevices.FirstOrDefault();
        }
        private void SelectCurrentDevice()
        {
            var guid = Settings.Default.SoundOutputGuid;

            if (guid != Guid.Empty)
            {
                var device = AudioDevices.FirstOrDefault(it => it.ProductGuid == guid);

                if (device.ProductGuid != Guid.Empty)
                {
                    CurrentAudioDevice = device;
                }
                else
                {
                    Settings.Default.SoundOutputGuid = Guid.Empty;
                    Settings.Default.Save();
                }
            }
            else
            {
                CurrentAudioDevice = null;
            }
        }
Ejemplo n.º 4
0
 private IEnumerable <AudioDevice> ConvertDeviceDescriptors(IEnumerable <AudioDevicesWatcher.AudioDeviceDescriptor> audioDeviceDescriptors)
 {
     return(audioDeviceDescriptors.Select(desc => AudioDevices.FirstOrDefault(x => x.AudioDeviceDescriptor != null && string.Equals(desc.Id, x.AudioDeviceDescriptor.Id))).Where(x => x != null).ToArray());
 }