一直在努力寻找一种方法来将音频从文件或Web传输到特定的输出设备,而不仅仅是默认的设备。使用mciSendString
尝试过,虽然open command确实接受设备ID /文件名,但我还没有找到使用它的方法,甚至不确定这是否是我在寻找的东西,但考虑到它说... or the filename of the device driver
在猜测是(?),但如果我错了,请纠正我,这不是specify your output device
类型参数。
如果是正确的方法,那么您如何枚举已安装的设备驱动程序,已经调查了IMMDevice
接口(interface),因为它看起来像是可以将文件名存储在注册表中,但没有输出设备注册表项具有driver filename
类型值条目,或者至少我还没有找到。
所以我的问题是,您如何将音频流传输到特定的输出设备,而不必通过mciSendString
完成,这只是我研究的内容,因为它是播放音频时最受关注的功能之一。
注意:请而不是向我推荐第三方库,例如NAudio,我问这个问题的原因不是获得库的建议,否则我会用过一个并且永远不会写这个,只是看到了很多答案就像:Use {LibName}, it has what you want
或类似的东西。
如果所写的内容在地方很奇怪或措词不正确,那么基本上这就是最终目标:
Installed Output Devices:
- Output1
- Output2
- Output3
Method For Playing:
//will play x.mp3 through output device 1
PlayAudio(output: "Output1", mp3File: "x.mp3");
//will play x.mp3 through output device 2
PlayAudio(output: "Output2", mp3File: "x.mp3");
//will play x.mp3 through output device 3
PlayAudio(output: "Output3", mp3File: "x.mp3");
最佳答案
您似乎在寻找此API:mciSendCommand()
mciSendCommand()
和MCI_SET
调用MCI_WAVE_SET_PARMS
将wOutput设置为所需的播放设备的ID。 IDDevice
:mciSendCommand(
它不是100%清楚
mciGetDeviceID("waveaudio")
想要什么,它可能与wOutput
返回的ID相同我只是个搬运工。
请引用:
https://stackoverflow.com/a/13320137/11128312
https://stackoverflow.com/a/10968887/11128312
关于c# - 如何将音频流传输到特定的输出设备?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58552660/