在Mac OS X中更改声音(或其他)系统首选项 [英] Change Sound (or other) System Preferences in Mac OS X

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

问题描述

我想要在Mac OS X中切换声音输出源,而不需要任何GUI交互。

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 ,但它必须是可编写脚本的。目标是通过一次击键在我的数字和模拟输出之间切换。我有一个帮助应用程序,将在一个按键上启动程序或应用程序。现在我需要的是应用程序或应用程序,无需任何用户交互即可快速切换声源。

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来设置<$ c $的属性 kAudioHardwarePropertyDefaultOutputDevice kAudioHardwarePropertyDefaultSystemOutputDevice c> AudioSystemObject (使用 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天全站免登陆