如何将音频流传输到特定的输出设备?

问题描述 投票:0回答:1

一直在寻找一种方法来将音频从文件或Web传输到特定的输出设备,而不仅仅是默认的设备。使用mciSendString进行了尝试,虽然open command确实接受设备ID /文件名,但我还没有找到使用它的方法,但甚至不确定这是否是我正在寻找的东西,但考虑到它说... or the filename of the device driver猜测是(?),但是如果我错了,请纠正我,这不是specify your output device类型参数。

如果是正确的东西,那么您如何枚举已安装的设备驱动程序,已经进入IMMDevice界面,因为它看起来像可以将文件名存储在注册表中,但没有输出设备注册表项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");
c# windows winapi audio audio-streaming
1个回答
0
投票

您似乎正在寻找此API:mciSendCommand()

设置多媒体使用的WaveAudio设备(声卡)控制时,必须使用mciSendCommand API。多媒体控制没有直接提供一种方法来让您设置用于播放或录制。

  • mciSendCommand()MCI_SET呼叫MCI_WAVE_SET_PARMS将输出设置为所需的播放设备的ID。
  • 然后通过IDDevice获得mciSendCommand(mciGetDeviceID("waveaudio")

不是100%清楚wOutput想要什么,它的ID可能与waveOutGetDevCaps()返回的ID相同

我只是个搬运工。

请参阅:

https://stackoverflow.com/a/13320137/11128312

https://stackoverflow.com/a/10968887/11128312

© www.soinside.com 2019 - 2024. All rights reserved.