Пример #1
0
 public void UpdateDevices()
 {
     VideoDevices.Clear();
     AudioDevices.Clear();
     MpsseDevices.Clear();
     PeachCam.EnumerateDevices();
 }
Пример #2
0
 private void RefreshAudioDevices(object sender, RoutedEventArgs e)
 {
     Dispatcher.BeginInvoke((Action)(() =>
     {
         var devices = Controller.GetPlaybackDevices(DeviceState.Active);
         AudioDevices.Clear();
         foreach (var d in devices.OrderBy(x => x.Name))
         {
             AudioDevices.Add(d);
         }
     }));
 }
        private void FillAudioDevices()
        {
            if (AudioDevices.Count > 0)
            {
                AudioDevices.Clear();
            }

            var deviceCount = WaveOut.DeviceCount;

            for (int i = 0; i < deviceCount; i++)
            {
                AudioDevices.Add(WaveOut.GetCapabilities(i));
            }
        }
Пример #4
0
        /// <summary>
        /// Updates the devices.
        /// </summary>
        private void UpdateDevices()
        {
            try
            {
                if (string.IsNullOrEmpty(this.FFmpegPath) || !File.Exists(this.FFmpegPath))
                {
                    return;
                }
            }
            catch { return; }

            var ffmpeg = new ProcessHelper(this.FFmpegPath)
            {
                Arguments = "-hide_banner -list_devices 1 -f dshow -i dummy"
            };

            ffmpeg.Start();
            var lines = ffmpeg.StandardError;

            var gettingVid = false;
            var gettingAud = false;

            AudioDevices.Clear();
            VideoDevices.Clear();

            foreach (var item in lines)
            {
                if (item.Contains("DirectShow video devices"))
                {
                    gettingVid = true;
                    gettingAud = false;
                    continue;
                }
                else if (item.Contains("DirectShow audio devices"))
                {
                    gettingAud = true;
                    gettingVid = false;
                    continue;
                }
                else if (string.IsNullOrEmpty(item) || item.Contains("Alternative name") || item.Contains("exit requested"))
                {
                    continue;
                }

                var quoteIndex = item.IndexOf("\"", StringComparison.Ordinal);
                if (quoteIndex < 0)
                {
                    continue;
                }

                var device = item.Remove(0, quoteIndex + 1);
                quoteIndex = device.IndexOf("\"", StringComparison.Ordinal);
                if (quoteIndex < 0)
                {
                    throw new ArgumentNullException(item);
                }

                device = device.Remove(quoteIndex);

                if (gettingAud)
                {
                    AudioDevices.Add(device);
                }
                if (gettingVid)
                {
                    VideoDevices.Add(device);
                }
            }

            OnDevicesUpdated();
        }