Search code examples
iphoneiosaudiolockingipod

applicationMusicPlayer stops when user locks the screen on iOS 5


I set the audio session category to kAudioSessionCategory_MediaPlayback, I active the session, which returns no errors, and still the iPod music stops when I lock the device. This happens on iOS 5 GM, so I guess this will happen in the final version. On iOS 4+ the current code works fine. Any ideas how to fix this? Huge thanks :)


Solution

  • It's not a bug. To save power locking the phone is now treated as if the user pressed the home button. The fact that applicationMusicPlayer stops now when locking is just a side effect of this change.

    To work around this problem you should switch to AVPlayer and make use iOS 4's audio in background mode.