What is the best pattern for an application to play sounds while enabling user to use his iPad app to play music as well? Right now if the music is playing any sound played by my app will stop the music. Is there a way to disable sounds while ipod is playing?
By default, sounds played interrupt iPod, as you have seen. In order to tell the system that you want the sounds you're playing to be mixed in with other sounds on the system, such as iPod, you need to set the category of your AVAudioSession
to AVAudioSessionCategoryAmbient
, like this:
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];
Do this before you begin playing sounds, and you should get the desired effect. Here's the documentation:
http://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVAudioSession_ClassReference/Reference/Reference.html#//apple_ref/doc/uid/TP40008240-CH1-SW1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With