Пример #1
0
        public static WaveOutDevice[] GetDevices()
        {
            MMDeviceEnumerator enumerator = new MMDeviceEnumerator();

            var devices = new WaveOutDevice[WaveOut.DeviceCount];

            for (int i = 0; i < devices.Length; ++i)
            {
                // MSDN:
                // If the value specified by the uDeviceID parameter is a device identifier,
                // it can vary from zero to one less than the number of devices present.
                devices[i] = new WaveOutDevice(i);

                foreach (MMDevice device in enumerator.EnumerateAudioEndPoints(DataFlow.All, DeviceState.All))
                {
                    try
                    {
                        if (device.FriendlyName.StartsWith(devices[i].Capabilities.ProductName))
                        {
                            devices[i].ProductName = device.FriendlyName;
                            break;
                        }
                    }
                    catch (COMException ex)
                    {
                        Debug.WriteLine(ex);
                    }
                }
            }

            return(devices);
        }
Пример #2
0
        private async void PopulateDeviceList()
        {
            var selectedDevice = deviceComboBox_.SelectedItem as WaveOutDevice;

            deviceComboBox_.Items.Clear();

            var devices = await WaveOutDevice.GetDevicesAsync();

            deviceComboBox_.Items.AddRange(devices);
            deviceComboBox_.SelectedItem =
                devices.FirstOrDefault(device => device.Guid == selectedDevice?.Guid);
        }
Пример #3
0
        private void PopulateDeviceList()
        {
            var selectedDevice = deviceComboBox_.SelectedItem as WaveOutDevice;

            deviceComboBox_.Items.Clear();

            var devices = WaveOutDevice.GetDevices();

            deviceComboBox_.Items.AddRange(devices);
            deviceComboBox_.SelectedItem =
                devices.FirstOrDefault(device => device.ToString() == selectedDevice?.ToString());;
        }
Пример #4
0
        public static WaveOutDevice[] GetDevices()
        {
            var deviceCollection = new DevicesCollection();
            var devices          = new WaveOutDevice[deviceCollection.Count];

            for (int i = 0; i < devices.Length; ++i)
            {
                devices[i] = new WaveOutDevice(deviceCollection[i].DriverGuid)
                {
                    DeviceInformation = deviceCollection[i]
                };
            }

            return(devices);
        }
Пример #5
0
        private void PopulateDeviceList()
        {
            var selectedDevice = deviceComboBox_.SelectedItem as WaveOutDevice;

            deviceComboBox_.Items.Clear();

            for (int i = 0; i < WaveOut.DeviceCount; ++i)
            {
                // MSDN:
                // If the value specified by the uDeviceID parameter is a device identifier,
                // it can vary from zero to one less than the number of devices present.
                var device = new WaveOutDevice(i, WaveOut.GetCapabilities(i));
                deviceComboBox_.Items.Add(device);

                if (device.DeviceNumber == selectedDevice?.DeviceNumber)
                {
                    selectedDevice = device;
                }
            }

            deviceComboBox_.SelectedItem = selectedDevice;
        }