【发布时间】:2011-07-24 16:02:57
【问题描述】:
我希望我的应用检查静音开关是打开还是关闭!但是有一个问题……有它的功能吗?
提前致谢
【问题讨论】:
我希望我的应用检查静音开关是打开还是关闭!但是有一个问题……有它的功能吗?
提前致谢
【问题讨论】:
How to programmatically sense the iPhone mute switch?
我相信这就是你要找的。p>
在这里发布代码:
// "Ambient" makes it respect the mute switch
// Must call this once to init session
if (!gAudioSessionInited)
{
AudioSessionInterruptionListener inInterruptionListener = NULL;
OSStatus error;
if ((error = AudioSessionInitialize (NULL, NULL, inInterruptionListener, NULL)))
{
NSLog(@"*** Error *** error in AudioSessionInitialize: %d.", error);
}
else
{
gAudioSessionInited = YES;
}
}
SInt32 ambient = kAudioSessionCategory_AmbientSound;
if (AudioSessionSetProperty (kAudioSessionProperty_AudioCategory, sizeof (ambient), &ambient))
{
NSLog(@"*** Error *** could not set Session property to ambient.");
}
【讨论】: