private string GetDefaultDevice()
        {
            FFmpegHandler handler  = new FFmpegHandler("ffmpeg", "ffmpeg.exe");
            NAudioHandler nHandler = new NAudioHandler();

            string[] devices       = new string[0];
            string   defaultDevice = nHandler.getDefaultDevice().ToString();
            string   ffmpegDevice  = string.Empty;

            handler.getInputDevices((string[] s) =>
            {
                devices = s;
            });
            Thread.Sleep(3000);
            foreach (string s in devices)
            {
                for (int i = 0; i < s.Length; i++)
                {
                    if (i == s.Length - 1 && s[i] == defaultDevice[i])
                    {
                        ffmpegDevice = s;
                        break;
                    }
                    if (s[1] != defaultDevice[1])
                    {
                        continue;
                    }
                }
            }
            return(ffmpegDevice);
        }
        private void setDefaultDevice()
        {
            MMDevice defaultDevice = nAudioHandler.getDefaultDevice();

            if (defaultDevice != null)
            {
                string defaultDeviceName = defaultDevice.ToString();
                foreach (string s in inputDevices.Items)
                {
                    for (int i = 0; i < s.Length; i++)
                    {
                        if (i == s.Length - 1 && s[i] == defaultDeviceName[i])
                        {
                            inputDevices.SelectedIndex = inputDevices.Items.IndexOf(defaultDeviceName.Substring(0, s.Length));
                        }
                        if (s[i] != defaultDeviceName[i])
                        {
                            continue;
                        }
                    }
                }
            }
            else
            {
                inputDevices.SelectedItem = null;
            }
        }
Exemple #3
0
        public void DefaultDevice()
        {
            var           enumerator    = new MMDeviceEnumerator();
            MMDevice      defaultDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Console);
            NAudioHandler handler       = new NAudioHandler();
            MMDevice      device        = handler.getDefaultDevice();

            Assert.AreEqual(device.ToString(), defaultDevice.ToString());
        }
        private void setDefaultDevice()
        {
            NAudioHandler nAudioHandler = new NAudioHandler();
            MMDevice      defaultDevice = nAudioHandler.getDefaultDevice();

            if (defaultDevice != null)
            {
                inputDevices.SelectedIndex = inputDevices.Items.IndexOf(defaultDevice.ToString());
            }
        }