tags:

views:

328

answers:

2

I'm using the MPMusicPlayerController application music player, created like:

appMusicPlayer = [MPMusicPlayerController applicationMusicPlayer];

The issue is that it will play music no matter which setting the device mute switch is in, it doesn't seem to care either way. Is there some audio session mode I need to be in to have it respect the mute switch?

+1  A: 

Yes. You want to use one of the following constants for your Audio Session Category:

kAudioSessionCategory_AmbientSound
kAudioSessionCategory_SoloAmbientSound

These are the ones that go silent when the Ring/Silent switch is set to silent.

mahboudz
Thanks for the suggestion, but it doesn't seem to be working. I've tried changing to one of those sessions via both the AudioToolbox and the AVFoundation but neither seems to affect the audio session for the MPMusicPlayerController. It still ignores the mute switch. For reference here's the latest way I'm attempting to set the session: [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategorySoloAmbient error: nil]; [[AVAudioSession sharedInstance] setActive: YES error: nil];
Matt Hall
A: 

Fwiw I'm seeing the same problem. I suspect that, like the iPod app itself, it will never respect the mute switch.

NeilInglis
... unless you implement the behavior yourself
dkk