简体   繁体   English

如何将 stream 音频传输到特定的 output 设备?

[英]How to stream audio to a specific output device?

Have been struggling with finding a way to stream audio, from a file or web, to a specific output device, not just the default one.一直在努力寻找从文件或 web 到特定 output 设备的 stream 音频的方法,而不仅仅是默认设备。 Tried using mciSendString and while the open command does accept a device id/filename I haven't found a way to make use of it, am not even sure if this is what I am looking for or not, but considering it says ... or the filename of the device driver am guessing yes(?), but correct me if I am wrong, and this isn't a specify your output device type parameter.尝试使用mciSendString并且 打开命令确实接受设备 ID/文件名,但我还没有找到使用它的方法,甚至不确定这是否是我正在寻找的,但考虑到它说... or the filename of the device driver猜测是(?),但如果我错了,请纠正我,这不是specify your output device类型参数。

If it is the correct thing then how do you enumerate the installed device drivers, have looked into the IMMDevice interface because it seamed like it could have the file names stored in the registry, but non of the output device registry keys had a driver filename type value entry, or at least I haven't found one.如果它是正确的,那么你如何枚举已安装的设备驱动程序,已经查看了IMMDevice接口,因为它看起来像是可以将文件名存储在注册表中,但是 output 设备注册表项没有driver filename类型值条目,或者至少我还没有找到一个。

So my question is, how would you go about streaming audio to a specific output device, it doesn't have to be done through mciSendString , that's just something I looked into as it's one of the most talked about function when it comes to playing audio. So my question is, how would you go about streaming audio to a specific output device, it doesn't have to be done through mciSendString , that's just something I looked into as it's one of the most talked about function when it comes to playing audio .

Note: please do not recommend me 3rd party libraries like NAudio, the reason I am asking this question is not get recommendations for libraries, otherwise I would have already used one and would have never written this, have just seen a lot of answers be like: Use {LibName}, it has what you want or something along those lines.注意:请不要向我推荐像 NAudio 这样的 3rd 方库,我问这个问题的原因是没有得到对库的推荐,否则我已经使用过一个并且永远不会写这个,刚刚看到很多答案就像: Use {LibName}, it has what you want的或类似的东西。

In case what's written is odd or incorrectly worded in places, basically this is what the end goal should be:如果所写的内容奇怪或在某些地方措辞不正确,基本上这就是最终目标应该是:

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");

You seem to be looking for this API: mciSendCommand()你好像在找这个 API: mciSendCommand()

To set the WaveAudio device (soundcard) used by the Multimedia Control, you must use the mciSendCommand API.要设置 Multimedia Control 使用的 WaveAudio 设备(声卡),您必须使用 mciSendCommand API。 The Multimedia Control does not directly provide a method to let you set the device used for playing or recording.多媒体控件不直接提供让您设置用于播放或录制的设备的方法。

  • Call mciSendCommand() with MCI_SET & MCI_WAVE_SET_PARMS setting wOutput to the desired playback device's ID.使用MCI_SETMCI_WAVE_SET_PARMS将 wOutput 设置为所需播放设备的 ID 调用mciSendCommand()
  • Then get IDDevice for mciSendCommand( ) via mciGetDeviceID("waveaudio")然后通过mciGetDeviceID("waveaudio") IDDevice mciSendCommand( ) 的 IDDevice

Its not 100% clear what wOutput wants, its probably the same ID as returned by waveOutGetDevCaps()它不是 100% 清楚wOutput想要什么,它可能与waveOutGetDevCaps()返回的 ID 相同

I am just a porter.我只是个搬运工。

Please refer:请参考:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM