I used AVQueuePlayer to play several items in background. And code worked perfect in iOS4. And in iOS5 AVQueuePlayer changed its behavior, so player stops playing after first item is ended.
Matt Gallagher wrote a hint in this post. "As of iOS 5, it appears that AVQueuePlayer no longer pre-buffers. It did pre-buffer the next track in iOS 4."
So my question is how to play several items in background using AVPlayer or AVQueuePlayer in iOS5.
Matt Gallagher's answer in his blog: "You must observe the current item in the AVQueuePlayer. When it changes, you must use UIApplication to start a backgroundTask and only end the background task when you receive a ready to play notification for the next file."
Actually, this did not helped me.
So my solution is:
I can't explain why, but this line of code put before adding new AVPlayerItem made my code work. Also for those one who adds next track in background and uses method
You must add AVPlayerItem to player on the main thread. like this:
UPDATE: Matt Gallagher was right, but it works only if you do not use asynchronous loading.