2
我需要選擇waveout設備來播放聲音。但我不能那樣做。NAudio WaveOut設備ID
void Initialize()
{
_WaveOut = new WaveOut();
var reader = new WaveFileReader(FileName);
_WaveOut.Init(new WaveChannel32(reader));
}
該函數啓動,然後窗體開始。在我的表單上,我選擇帶組合框的Waveout設備。 Combobox是filles與此代碼:
for (int i = 0; i < WaveOut.DeviceCount; i++)
{
WaveOutCapabilities WOC = WaveOut.GetCapabilities(i);
comboBox2.Items.Add(WOC.ProductName);
}
在此之後,我選擇我的設備。
int WaveOutDeviceId = comboBox2.SelectedIndex;
然後開始播放功能:
void Play()
{
_WaveOut.DeviceNumber = WaveOutDeviceId;
_WaveOut.Play();
}
但我的聲音總是默認設備(擁有數= 0)上播放。如果我爲麥克風這樣做,此代碼正常工作。
謝謝,你的回答是非常有幫助的。 – EXTRAM