简体   繁体   English

iOS:AVQueuePlayer/AVPlayerItem '一个 AVPlayerItem 一次只能占据玩家队列中的一个位置。

[英]iOS: AVQueuePlayer/AVPlayerItem 'An AVPlayerItem can occupy only one position in a player's queue at a time.'

I keep getting this error:我不断收到此错误:

'An AVPlayerItem can occupy only one position in a player's queue at a time.' “一个 AVPlayerItem 一次只能占据玩家队列中的一个位置。”

I NSLog'd the players items, and none of them seem to be equal.我 NSLog'd 的球员项目,他们似乎都不是平等的。 Further, I added this just to be sure:此外,我添加了这个只是为了确定:

if([player canInsertItem:itemToAdd afterItem:nil])
 [player insertItem:itemToAdd afterItem:nil];

When I wasn't sure if that would work (can have two identical items in different memory locations) I wrote a category method to test if a player contains an item or something identical to it.当我不确定这是否可行(可以在不同的内存位置有两个相同的项目)时,我编写了一个类别方法来测试玩家是否包含一个项目或与之相同的东西。 Yet, I'm still getting the error.但是,我仍然收到错误消息。

I've seen several posts of people getting this error with MPMoviePlayerController, but I'm not using that custom class, just the out of the box AVQueuePlayer.我已经看到一些人在使用 MPMoviePlayerController 时遇到此错误的帖子,但我没有使用该自定义类,只是开箱即用的 AVQueuePlayer。

Any ideas on how to fix this?有想法该怎么解决这个吗?

There is a similar question .有一个类似的问题

It does not have an accepted answer, but it seems like plenty of people are having the same problem.它没有一个公认的答案,但似乎很多人都遇到了同样的问题。
Also, see this post from the Apple Dev Forum.另外,请参阅来自 Apple Dev Forum 的这篇文章

I've met with similar problems.我遇到过类似的问题。 You might have used AVPlayerLooper along with AVQueuePlayer I suppose?我想您可能已经将 AVPlayerLooper 与 AVQueuePlayer 一起使用了? In the description it says :在描述中它说:

The specified AVPlayerItem will be used as a template to generate at least 3 AVPlayerItem replicas and the replicas will be inserted into specified AVQueuePlayer's play queue to accomplish the looping playback.以指定的AVPlayerItem为模板,生成至少3个AVPlayerItem副本,并将副本插入到指定AVQueuePlayer的播放队列中,完成循环播放。

In that case at some point when you called functions like replaceCurrentItem, the error may occur.在这种情况下,当您调用诸如 replaceCurrentItem 之类的函数时,可能会发生错误。

For now I can only guess the cause of such error, I'll update when further tests are done.目前我只能猜测这种错误的原因,当进一步的测试完成时我会更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM