Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
453 views
in Technique[技术] by (71.8m points)

iphone - Pre-buffering for AVQueuePlayer

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...