I have an AVQueuePlayer based audio stream player that needs to run in the background. The player must continue to work until he finishes playing the entire list. Of course, you will need to pause if the network connection deteriorates, but it should automatically resume when the network connection returns.
For this I am tracking
AVPlayerItem.statusAVPlayerItem.playbackLikelyToKeepUpAVPlayer.currentItemAVPlayer.statusAVPlayer.error
using KVO. For example, if a network connection is restored from a temporary error, I expect currentAVPlayerItem.status become the AVPlayerStatusItemReadyToPlay reported to my player, and I can release [AVQueuePlayer play] at this point.
This mechanism (logic) seems to work in some cases, but quite often in offline mode, AVPlayerItem.status becomes AVPlayerItemStatusFailed , which the AVQueuePlayer seems to skip automatically. As a result, the queue will be empty and feedback cannot be received from AVPlayerItem .
I was hoping that some property in AVPlayer will change when the network connection deteriorates / restores, but nothing changes ( status , error , etc.).
Obviously, I can track Reachability , but this does not work when the application is running in the background.
How do I know when the network is back and AVQueuePlayer is playing again in this situation?
I may just be a beginner in this area. If someone can give me a general idea of how he / she achieves a continuous experience playing AVQueuePlayer without being completely stopped by temporary network connectivity issues, this will be a huge help too!
ios iphone audio avplayer avqueueplayer
barley
source share