1
可能重复:
How to programatically sense the iPhone mute switch?有没有办法检查静音状态?
我想我的应用程序请检查是否静音开关切换或关闭!但是有一个问题...是否有一个功能呢?
在此先感谢
可能重复:
How to programatically sense the iPhone mute switch?有没有办法检查静音状态?
我想我的应用程序请检查是否静音开关切换或关闭!但是有一个问题...是否有一个功能呢?
在此先感谢
How to programmatically sense the iPhone mute switch?
我相信这是你在找什么。
发布代码在这里:
// "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.");
}