Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pre-buffering for AVQueuePlayer

Tags:

Does anyone know if AVQueuePlayer starts buffering the next AVPlayerItem when the current item is about to finish playing?

I know there's nothing in the docs to suggest this, I'm asking mostly if anyone has observed this kind of behavior or not.

like image 827
Mihai Damian Avatar asked Nov 18 '10 18:11

Mihai Damian


1 Answers

Ok, I've looked over this problem again and written some code to check out AVQueuePlayer.

jollyCocoa's answer pointed me in the right direction by suggesting to observe the status property on AVPlayerItem. However the documentation doesn't seem to point out that this property (and it's AVPlayerItemStatusReadyToPlay value in particular) might be related to buffering.

However the AVPlayerItem's loadedTimeRanges property seems more related to buffering.

Doing KVO on that array was a bit trickier - the array object itself doesn't change, only it's items do - so I resorted to printing out it's content every second.

What I found out is that a few seconds in the queue's first item, the loadedTimeRanges for the second item shows up a new CMTimeRange with start time 0 and some small duration. The duration can increase up to 60 or so seconds while the previous item keeps playing.

Short answer: AVQueuePlayer will buffer the next AVPlayerItem while playing the current one.

like image 102
Mihai Damian Avatar answered Sep 18 '22 06:09

Mihai Damian