本文介绍了在Snow Leopard中控制OS X音量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是对介绍了如何将音量设置为10.5或更早版本。 AudioXXXXXGetProperty AudioXXXXXSetProperty (及相关)函数在。

This is a follow up to Controlling volume of running applications in Mac OS X via Objective-C, which explains how to set the volume for 10.5 or earlier. The AudioXXXXXGetProperty, and AudioXXXXXSetProperty (and related) functions are deprecated in 10.6, per Technical Note TN2223.

我不是OS X或CoreAudio编程的专家,所以我希望有人弄清楚Snow Leopard的要求,并可以在这里帮助我(和其他人)。

I'm not an expert in OS X or CoreAudio programming, so I'm hoping someone has muddled through what's required in Snow Leopard and can help me (and others) out here.

推荐答案

下面是将音量设置为50%的示例:

Here's an example to set volume to 50%:

Float32 volume = 0.5;
UInt32 size = sizeof(Float32);

AudioObjectPropertyAddress address = {
    kAudioDevicePropertyVolumeScalar,
    kAudioDevicePropertyScopeOutput,
    1 // use values 1 and 2 here, 0 (master) does not seem to work
};

OSStatus err;
err = AudioObjectSetPropertyData(device, &address, 0, NULL, size, &volume);

这篇关于在Snow Leopard中控制OS X音量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 16:04