Reading the Silent Switch?
Also note that setting the session to ambient works fine with OpenAL, but not with Audio Queues. With Audio Queues, the system apparently tries to pipe audio through the same single hardware decoder as iTunes, if the user had played music, or turns on iTunes during your game (double-clicking the home button). This can freeze the device, requiring a reboot!
Sweet, that's exactly what I needed. And it solved another issue with the game audio stopping any iPod playback. Here's the code I used for anyone searching in the future. Just stick it before any OAL initialization.
// The audio session setup
UInt32 sessionCategory = kAudioSessionCategory_AmbientSound;
AudioSessionInitialize(NULL, NULL, interruptionListenerCallback, self);
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
// The interruption callback
void interruptionListenerCallback(void *inUserData, UInt32 interruptionState)
MySoundController *controller = (MySoundController *)inUserData;
if (interruptionState == kAudioSessionBeginInterruption)
// stop sound/music here
[controller stopPlaying]; // or whatever
else if (interruptionState == kAudioSessionEndInterruption)
// resume any sound/music necessary here
[controller resumePlaying]; // etc
Possibly Related Threads...
|How do I get iPod Player to respect silent switch?||CVogelbusch||0||1,767||
Nov 25, 2009 05:34 AM
Last Post: CVogelbusch
|Added openfient, switch to c++ duplicate symbol||kendric||7||3,637||
Aug 9, 2009 02:47 AM
Last Post: backslash