Alex Yurkowski Alex Yurkowski - 3 months ago 33
iOS Question

AVPlayer is never ready to play

I have an

AVPlayer
that is loading a remote media
URL
(
HLS
stream) and sometimes the player is never ready to play, but no error is presented. Is there somewhere else an error can be or a way to check if it is still loading the
AVPlayerItem
?

I have
KVO
for rate, status, and playback likely to keep up which never get called when the video isn't loading. I added a button to check for an error on the player, the player item, and whether playback is likely to keep up. These report nil, nil, and false when the player seems stuck. It seems random when the player gets stuck(refuses to load vidoe at all), it doesn't happen on a specific video.

What other steps can I take to debug this issue? Are there other places to check for errors or status?

More info checked:
Playback buffer is empty: true
Playback buffer is full: false

Answer

Our solution is before reusing the player, we deallocated the AVPlayer by using player.replaceCurrentItemWithPlayerItem(nil). Some reason replacing the current item sometimes caused issues. We also made sure our videos were loading in order, rather than all at once. That seemed to have solved our issue.

Comments