控制 avqueueplayer 中项目的预缓冲
请有人告诉我是否有一种方法可以选择性地预缓冲 AVQueuePlayer 数组中的 avplayeritems,而不是将其保留为仅加载下一个的 AVQueuePlayer 自动方式当第一个项目播放完毕时,项目就会进入。
我正在加载 4 个短片剪辑的序列,并且我想在告诉 AVQueuePlayer 播放数组之前预先缓存它们。实际上是否有一种方法可以进入 avqueueplayer 的控制并根据需要控制预缓冲?
现在,由于其默认的延迟加载行为,我在播放时遇到了一些卡顿,剪辑甚至无法正常播放,因为 AVQueuePlayer 正在尝试加载下一个剪辑。玩。我是在部署到实际设备的 iPad 上执行此操作,而不是使用模拟器。
您可以通过调用 [playerprepareToPlay];
使用 mpmovieplayer 来执行此操作,这基本上会手动启动所需的每个视频文件的加载,然后您可以通过观看 来检查加载是否完成mpmovieplayerLoadstateDidChange
通知并测试 loadState
值以查看其是否已完全加载,然后告诉 mpmovieplayer 进行播放。如何使用 AVQueuePlayer 有效地完成类似的事情?
这是否可能,或者我是否发现了 AVQueuePlayer 的主要缺点之一?
斯蒂芬对playerObserver提出了很好的建议,但是您需要的是能够显式地将单个项目加载到内存中,然后告诉AVQueuePlayer“不要”播放数组中的第一个项目,直到数组中的所有项目都加载到内存中' 目前似乎无法启动数组中的第二个项目加载,直到第一个项目结束!
作为一个稍微独立的问题,我还注意到 AVQueuePlayer 中的一些奇怪之处,如果您将两个相同的源视频文件加载到数组中(两者都被引用为两个完全独立的 AVPlayerItems< /code> 正如您应该做的那样)当您一路播放数组中的视频剪辑时,第一次剪辑播放正常,但是当再次播放同一剪辑时(作为单独的 AVPlayerItem< /代码>)它播放速度非常快,直到视频中的某个点,然后最终从那里开始以正常速度播放。
还有其他人注意到这种行为吗?
Please can someone tell me if there is a way to selectively pre-buffer the avplayeritems in the AVQueuePlayer
array rather than leaving it down to the AVQueuePlayer
automatic way of only loading the next item in as the first item finishes playing.
I'm loading a sequence of 4 short movie clips and I'd like to pre-cache them before telling the AVQueuePlayer
to play the array. Is there actually a way of getting under the bonet of avqueueplayer and controlling the pre-buffering as desired?
Right now with its default lazy-loading behaviour, I'm getting some chugging in the playback, with the clips not even playing-out properly because the AVQueuePlayer
is trying to loading-in the next clip while it's playing. I'm doing this on iPad deployed to the actual device and not with the simulator.
You can do this with the mpmovieplayer by calling [player prepareToPlay];
which basically manually initiates the loading of each video file you want and then you can check for the completeion of loading by watching for the mpmovieplayerLoadstateDidChange
notification and testing the loadState
value to see if it has fully loaded ,then telling the mpmovieplayer to play. How can you effectively do a similar thing with AVQueuePlayer
?
Is this even possible or have I discovered one of the major drawbacks of the AVQueuePlayer
?
Nice suggestion with the playerObserver
Stephen, but what is needed is something like you need to be able to explicitly get individual items to load into memory and then tell the AVQueuePlayer
'do not play the first item in the array until ALL items in the array are loaded into memory' There currently seems to be no way to start even the second item in the array loading until the first one is coming to an end!
As a slightly separate issue, I've also noticed some weirdness in the AVQueuePlayer
where, if you load two of the same source video file into the array (both referenced as two completely separate AVPlayerItems
as you should do) when you play the video clips in the array all the way through, the first time the clip plays through ok, but when it comes to playing that same clip again (as a separate AVPlayerItem
) it plays-through very quickly until a certain point in the video then finally starts playing at normal speed from there.
Has anyone else noticed this behaviour?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Apple 开发人员支持刚刚向我确认 AVQueuePlayer 不会缓冲视频项目。
Apple Developer Support just confirmed to me that AVQueuePlayer does not buffer video items.
我有同样的问题。我希望 AV Foundation 有类似资产满载通知之类的东西。
以下代码可以部分解决该问题:
I have the same question. I wish AV Foundation has something like asset fully loaded notification.
Following code may partially solve the problem: