My app uses AVAudioPlayer to play through audio playlists. I haven't changed the code between iOS4.3 and iOS5. However, the audio on iOS5 pauses on a screen lock even though I've set the category to be AVAudioSessionCategoryPlayback.
I've tested the code on iOS4.3 and iOS5 devices and this problem occurs on the iOS5 device.
Has anyone else faced this problem? I'm at a loss since I don't even know where to start debugging this issue. My debugging started and ended with checking the AVAudioSessionCategory setting.
The code where I'm doing it is:
[[AVAudioSession sharedInstance] setDelegate: self];
NSError *setCategoryError = nil;
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryError];
Edit:
I have already implemented and handled audioPlayerBeginInterruption
Edit #2: Solved! Thanks to Rhythmic Fistman's Answer
Here's what was happening and what I did. iOS5 changes now push your app to the background even when the screen gets locked. This means that you need to enable background audio in your app, and make whatever view/viewcontroller handling that audio to be the first responder.
Step 1: Enable background audio in your app
NOTE: Make sure to test this on the device. The simulator will make it seem like the code did not work.