So I've just noticed that on my iPod Touch, when my app triggers a short wav file to play using AVAudioPlayer, the music gets paused. Is this normal?
I can't find any reference to this, and it seems like it would be noted somewhere. Is there a way to keep the music going while I play my sounds?
Basically, every app is assigned an audio session which is modelled as a singleton class which you can get at application launch and set parameters to. The way I fixed the same problem was through a single line of code placed at applicationDidFinishLaunching
:
Objective-C:
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];
Swift 2/3:
try! AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryAmbient)
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