AVQueuePlayer的预缓冲 [英] Pre-buffering for AVQueuePlayer

查看:156
本文介绍了AVQueuePlayer的预缓冲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当当前项目即将完成播放时,有没有人知道 AVQueuePlayer 是否开始缓冲下一个 AVPlayerItem ? / p>

我知道文档中没有任何内容可以暗示这一点,我主要询问是否有人观察过这种行为。

解决方案

好的,我再次查看了这个问题并写了一些代码来查看 AVQueuePlayer



jollyCocoa的回答通过建议观察 AVPlayerItem 上的状态属性,向我指出了正确的方向。但是文档似乎没有指出这个属性(特别是它的 AVPlayerItemStatusReadyToPlay 值)可能与缓冲有关。



然而 AVPlayerItem的 loadedTimeRanges 属性似乎与缓冲更相关。



在那个数组上做KVO有点棘手 - 数组对象本身不会改变,只有它的项目才会改变 - 所以我每秒都要打印出它的内容。



我发现队列的第一项是几秒钟,第二项的 loadedTimeRanges 显示新的 CMTimeRange ,开始时间为0,持续时间较短。上一项继续播放时,持续时间最多可增加60秒。



简答: AVQueuePlayer 将播放当前的<$ p $ c> AVPlayerItem 。


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.

解决方案

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.

这篇关于AVQueuePlayer的预缓冲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆