在 Mac OS X 中更改声音(或其他)系统偏好设置 [英] Change Sound (or other) System Preferences in Mac OS X

查看:46
本文介绍了在 Mac OS X 中更改声音(或其他)系统偏好设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在没有任何 GUI 交互的情况下在 Mac OS X 中切换声音输出源.

I'd like to be able to switch the sound output source in Mac OS X without any GUI interaction.

有一些工具可以控制声音输出,例如 SoundSource 和一个 applescript 打开首选项对话框.

There are tools to do control the sound output, such as SoundSource and an applescript to open the preferences dialog.

我正在寻找的是可以立即切换偏好的东西,例如 SoundSource 但它必须是可编写脚本的.目标是一键在我的数字和模拟输出之间切换.我有一个 helper 应用程序,它将在一个按键上启动一个程序或 applescript.我现在需要的只是无需任何用户交互即可快速切换声源的 applescript 或应用程序.

What I am looking for is something that switches the preference instantly, like SoundSource but it has to be scriptable. The goal is to switch between my digital and analog output with one keystroke. I have a helper application that will launch a program or applescript on one keypress. All I need now is the applescript or application that switches the sound source quickly without any user interaction.

如果需要,我愿意编写一些 Objective-C,但我几乎是 Cocoa 开发的新手.

I'm willing to write some Objective-C if that is what it takes, but I'm pretty much a newbie at Cocoa development.

您是否有一个一键式解决方案,或者可以为我提供有关从 Cocoa 应用程序或命令行控制声音系统首选项的好教程?

Do you have a one-click solution or can point me to a good tutorial on controlling sound system preferences from a Cocoa App or command line?

编辑:我创建了一个命令行应用程序来执行此操作.您可以在 http://code.google.com/p/switchaudio-osx/下载它下载.项目站点上也提供了源代码.

EDIT: I created a command-line application to do exactly this. You may download it at http://code.google.com/p/switchaudio-osx/downloads. Source code is available on the project site as well.

推荐答案

不要从喜好的角度考虑;对于这类事情,没有集中的系统偏好框架.我相信您需要做的是使用 Core Audio 设置 AudioSystemObjectkAudioHardwarePropertyDefaultOutputDevice kAudioHardwarePropertyDefaultSystemOutputDevice 属性(使用 AudioHardwareSetProperty()).

Don’t think of it in terms of preferences; there’s no centralized system preference framework for this sort of thing. I believe what you need to do is use Core Audio to set the kAudioHardwarePropertyDefaultOutputDevice and kAudioHardwarePropertyDefaultSystemOutputDevice properties of the AudioSystemObject (using AudioHardwareSetProperty()).

这篇关于在 Mac OS X 中更改声音(或其他)系统偏好设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆