Pre-buffering for AVQueuePlayer

前端 未结 6 2064
-上瘾入骨i
-上瘾入骨i 2020-11-28 04:23

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

I know there\'s

6条回答
  •  佛祖请我去吃肉
    2020-11-28 04:36

    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.

提交回复
热议问题