我需要选择波形输出设备,以播放声音。但我不能这么做。
void Initialize()
{
_WaveOut = new WaveOut();
var reader = new WaveFileReader(FileName);
_WaveOut.Init(new WaveChannel32(reader));
}此函数将启动,然后窗体将启动。在我的表单上,我选择了waveout device with combobox。Combobox由以下代码填充:
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)。如果我对麦克风执行此操作,此代码将正常工作。
发布于 2012-11-07 22:27:19
一旦调用了Init,就来不及更改DeviceId了。当你想更换设备时,我建议创建一个新的WaveOut实例。
https://stackoverflow.com/questions/13266904
复制相似问题