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.");
}