C# 如何以编程方式更改播放设备
如何以编程方式更改 vista / win 7 系统上的默认音频设备?使用 C# 或 Win API 调用?
How can I programatically change the default audio device on a vista / win 7 system? Using C# or a Win API call?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
WinMM API 应提供您请求的功能。
您将使用 DRVM_MAPPER_PREFERRED_SET 消息,该消息通过 waveOutMessage() 函数发送。
文档: http://msdn.microsoft.com/en-us/library/ aa909789.aspx
但是,如果您尝试自己发送波形声音,则应该查看 WinMM.Net 库。
http://winmm.codeplex.com
The WinMM API should provide the functionality that you request.
You would use the DRVM_MAPPER_PREFERRED_SET message, which is sent with waveOutMessage() function.
Documentation: http://msdn.microsoft.com/en-us/library/aa909789.aspx
However, if you are trying to send the waveform sound out yourself, you should look at the WinMM.Net library.
http://winmm.codeplex.com
我发现
AudioSwitcher
构造函数在我的情况下特别慢。我建议使用 "CoreAudio " 用于管理音频设备的 API。
这是当前的包装器库可在 NuGet 上使用。
https://github.com/morphx666/CoreAudio/tree/master
设置设备:
获取设备
I found the
AudioSwitcher
constructor to be extra slow in my case.I suggest using the "CoreAudio" API for managing audio devices.
Here is a current wrapper library available on NuGet.
https://github.com/morphx666/CoreAudio/tree/master
Set device:
Get devices
现在(实际上已经很长一段时间了)可以使用 AudioSwitcher.AudioApi 轻松完成此操作.CoreAudio NuGet 包。
只需创建一个新的 CoreAudioController:
使用其 GUID 获取所需的设备:
最后将其设置为默认播放设备:
This can now (actually for quite some time already) be done very easily using the AudioSwitcher.AudioApi.CoreAudio NuGet package.
Simply create a new
CoreAudioController
:Get hold of the desired device using its GUID:
And lastly set it as the default playback device: