In my latest app, in one screen I play music files one at a time, on another page I record and play music files, and on yet another I play two music files simultaneously. The latest and hopefully last bug that I found was that sometimes when I switched back to a screen, I could no longer hear sound.
It turns out that I had my AvAudioSession category set to AVAudioSessionCategoryPlayback all the time. This setting needs to be changed when I change screens.
- To play one sound by itself: AVAudioSessionCategoryPlayback
- To play multiple sounds simultaneously: AVAudioSessionCategoryAmbient
- To record and play: AVAudioSessionCategoryPlayAndRecord
Hope this helps someone. I set the appropriate category in ViewWillAppear: [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];