4

I keep getting this error:

'An AVPlayerItem can occupy only one position in a player's queue at a time.'

I NSLog'd the players items, and none of them seem to be equal. 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.

Any ideas on how to fix this?

JoshDG
  • 3,871
  • 10
  • 51
  • 85

2 Answers2

0

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.

Community
  • 1
  • 1
IluTov
  • 6,807
  • 6
  • 41
  • 103
0

I've met with similar problems. You might have used AVPlayerLooper along with AVQueuePlayer I suppose? 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.

In that case at some point when you called functions like replaceCurrentItem, the error may occur.

For now I can only guess the cause of such error, I'll update when further tests are done.

LiLi Kazine
  • 195
  • 2
  • 9