设置声音输出/输入
我一直在网上寻找,但我不知道是否可能:Cocoa Mac OS X 应用程序可以更改声音输入/输出设备吗?如果是这样,怎么会这样呢?
I've been looking all over the web, but I don't know if it is possible: can a Cocoa Mac OS X app change the sound input/output device? If so, how come?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,通过 设置 相关音频系统对象属性。
可能是因为用户可能想要从应用程序内更改默认输入或输出设备,而不是必须在前后跳转到声音预窗格或使用额外的声音菜单。
Yes, by setting the relevant Audio System Object property.
Probably because the user might want to change the default input or output device from within an application, rather than having to jump over to the Sound prefpane before and after or use the Sound menu extra.
我知道这是一篇旧文章,但这些天我一直在努力寻找一种使用代码更改声音输入/输出设备的方法,我终于找到了如何做到这一点。如果其他人遇到同样的问题,这就是答案!
有一个名为 SwitchAudio-OSX 的命令行实用程序 (https://code.google.com/p/ switchaudio-osx/),允许您从终端切换音频源。它是开源的,您可以在这里找到最新版本:https://github.com/deweller/switchaudio -osx。
无论如何,您可以使用这些行来更改声音输入/输出设备:
其中
newDeviceID
是AudioDeviceID
的实例,代表您要选择的设备的 ID。此外,可以使用以下代码获取所有可用设备的列表:I know this is an old post but I've been struggling these days trying to find a way of changing the sound input/output device using code and I finally found how to do it. In case someone else runs into the same problem, here's the answer!
There's a command line utility called SwitchAudio-OSX (https://code.google.com/p/switchaudio-osx/) that allows you to switch the audio source from the terminal. It is open-source and you can find the latest version here: https://github.com/deweller/switchaudio-osx.
Anyway, you can use these lines to change the sound input/output device:
Where
newDeviceID
is an instance ofAudioDeviceID
and represents the id of the device you want to select. Also, a list of all available devices can be obtained using this code: