Reputation: 1187
I am using AVPlayer
to stream video remotely. Whenever I scrub and use seekToTime it works, and the video plays from the location, however if I do this enough times sequentially then the completion handler of seekToTime
never returns with "finished == YES" and is stuck.
Also, when profiling the connections it shows that the buffer never loads again even if seekToTime
is called again after that. I can drag the scrubber to the beginning and playback will resume however it is not buffering anymore so it will get stuck in a "buffering" state once the buffer runs out but no buffer will be downloading.
Any ideas what might be wrong?
Upvotes: 0
Views: 1401
Reputation: 10961
I had this problem for a long time, but also noticed that even if the seek never completed, I would quickly get a current playback position update (via the block passed to addPeriodicTimeObserverForInterval:queue:usingBlock:
) that matched the target seek.
It appears, though, that I was doing some things in the wrong order when initializing the player with an item. I would set an item, and when the player's status became AVPlayerStatusReadyToPlay
I would begin the seek, and it would never complete. But if I don't begin the seek until the current player item status is AVPlayerItemStatusReadyToPlay
, everything works great.
Upvotes: 2
Reputation: 1187
The problem was with the content distribution network. The streaming url was expiring and then would no longer stream to the player
Upvotes: 1