Trying to force audio device into NAudio player in C#

  • Thread starter Thread starter gavin2812
  • Start date Start date
G

gavin2812

Guest
Hello,


First post here!


I am trying to force an audio device into an NAudio player but I've been unable to work it out. At the moment, the code I have inherited uses a comboBox to select the device and use it, but I want to hard code it in.

From the code below in the commented lines you can see what I have already tried, but they all show errors so I am not getting it right somehow.

Can anyone help me with this?

The outcome I desire is to 'force' the NAudio to use the "Speakers (High Definition Audio Device)" audio device instead of selecting it from the combo box.

Thank you


NAudio.CoreAudioApi.MMDeviceEnumerator enumerator = new NAudio.CoreAudioApi.MMDeviceEnumerator();
var devices = enumerator.EnumerateAudioEndPoints(NAudio.CoreAudioApi.DataFlow.All, NAudio.CoreAudioApi.DeviceState.Active);
Globals.NewDevice = devices.ToString();
comboBox1.Items.AddRange(devices.ToArray());



if (comboBox1.SelectedItem != null)
{
var device = (NAudio.CoreAudioApi.MMDevice)comboBox1.SelectedItem;
//var device = (NAudio.CoreAudioApi.MMDevice.Equals.("Speakers (High Definition Audio Device)");
//var device = (NAudio.CoreAudioApi.MMDevice)."Speakers (High Definition Audio Device)";
//var device = (NAudio.CoreAudioApi.MMDevice)"Speakers (High Definition Audio Device)";
//var device = NAudio.CoreAudioApi.MMDevice."Speakers (High Definition Audio Device)";
//var device = (NAudio.CoreAudioApi.MMDevice.ReferenceEquals."Speakers (High Definition Audio Device)");
}

Continue reading...
 
Back
Top