AVQueuePlayer 同时播放项目而不是按顺序播放项目
我正在尝试编写一个简单的应用程序来播放预滚动视频,然后播放一些内容视频。
目前,我正在尝试使用 AVQueuePlayer 类来完成此任务。不幸的是,它似乎想按顺序正确播放视频。
例如,预卷自行播放几秒钟,然后(在预卷完成之前)开始尝试播放内容视频。有几秒钟,播放器似乎在与自己交战,并在两个视频之间来回切换(播放效果都不是很好)。最后,当预卷完成后,内容视频将正常播放剩余部分。
我浏览了 AVQueuePlayer 的文档,没有发现任何明显遗漏的内容。
我的代码非常基本:
AVPlayerItem *preRollItem = [AVPlayerItem playerItemWithURL: preRollUrl];
AVPlayerItem *contentItem = [AVPlayerItem playerItemWithURL: contentUrl];
self.player = [AVQueuePlayer queuePlayerWithItems:[NSArray arrayWithObjects:preRollItem, contentItem, nil]];
[self.player play];
让视频按顺序播放的技巧是什么。
I am trying to put together a simple app to play a pre-roll video followed by some content video.
Currently, I'm trying to use the AVQueuePlayer class to get this done. Unfortunately, it seems to want to play the videos properly in sequence.
For example, the pre-roll plays by itself for a few seconds, then (prior to the pre-roll being complete) it starts to try and play the content video. For a few seconds, the player seems to be at war with itself and switches back and forth between the two videos (neither playing very well at all). Finally, when the pre-roll is finished, the content video then plays the rest of the way normally.
I've looked through the documentation for the AVQueuePlayer and I don't see anything obvious that I'm missing.
My code is pretty basic:
AVPlayerItem *preRollItem = [AVPlayerItem playerItemWithURL: preRollUrl];
AVPlayerItem *contentItem = [AVPlayerItem playerItemWithURL: contentUrl];
self.player = [AVQueuePlayer queuePlayerWithItems:[NSArray arrayWithObjects:preRollItem, contentItem, nil]];
[self.player play];
What is the trick to getting the videos to play in sequence.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保您实际上是在设备上进行测试。根据我的经验,iOS5 模拟器在
AVQueuePlayer
方面存在很大问题,并且会做出一些奇怪的事情。我发现 iOS4.3 模拟器在测试 AVFoundation 方面做得更好。
Make sure you are actually testing on the device. From my experience the iOS5 simulator has big problems with
AVQueuePlayer
and does bizarre things.I found the iOS4.3 simulator is doing a much better job when it comes to testing AVFoundation.