ОБНОВЛЕНИЕ: Извините, приведенный ниже код работает хорошо для меня, но я использую iOS4.Для iOS5 этот ответ решит вашу проблему - Обнаружение переключателя Ring / Silent / Mute на iPhone с помощью AVAudioPlayer не работает?
Этот фрагмент кода - то, что вам нужно.Определить глобальный gAudioSessionInited
вар.Этот флаг говорит вам, включен ли ваш выключатель звука.
// "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.");
}