7

Im getting this error when trying to play a video from my temp directory:

NSString *tmpDir = [NSTemporaryDirectory() stringByAppendingString:@"/"];
NSString *url = [tmpDir stringByAppendingString:videoToPlay];

MPMoviePlayerController *player =
[[MPMoviePlayerController alloc]
 initWithContentURL:[NSURL fileURLWithPath:url]];

Why am i getting this error "An AVPlayerItem can occupy only one position in a player's queue at a time."

Isnt that code correct? Am i missing something simple?

Scoota P
  • 2,622
  • 7
  • 29
  • 45
  • 2
    Are your experiencing this on iOS5 beta 2? You should check the Apple Developer Forums, since I solved the same problem following the advice of Peter Harley here https://devforums.apple.com/message/467199. Hope it helps. – sigsegv Jul 07 '11 at 08:57
  • Yes i am. And that fixed the issue. You are the man! – Scoota P Jul 08 '11 at 03:08

5 Answers5

2

I tried various solutions provided in apple dev forums. In my case what worked was just changing the source type from streaming to unknown:

// player.movieSourceType = MPMovieSourceTypeStreaming;

  player.movieSourceType = MPMovieSourceTypeUnknown;
kzia
  • 559
  • 3
  • 8
  • 17
1

Use following statement to avoid such error. Please keep in mind that, THE sdk that you are using is under NDA.

[self.mPlayer.moviePlayer setControlStyle:MPMovieControlStyleDefault];

sagarkothari
  • 24,520
  • 50
  • 165
  • 235
0

I got this because i had invalid parameters for movieSourceType, i thought you were supposed to put a MPMovieMediaTypeMask in there (video/audio,etc) but instead you are supposed to put a MPMovieSourceType. Fixing that made it work for me

mgrandi
  • 3,389
  • 1
  • 18
  • 17
0

This happened to me when trying to use replaceCurrentItem on my AVQueuePlayer.

Apple states you should NOT use this method with AVQueuePlayer: https://developer.apple.com/documentation/avfoundation/avplayer/1390806-replacecurrentitemwithplayeritem

Instead I'm testing removeAllItems() and insert(AVPlayerItem, after: AVPlayerItem?) with a nil value for AVPlayerItem.

iOS12 Swift 5.

Jprofficial
  • 329
  • 3
  • 10
0

try to check control style and source type. Im getting this error ,and when change source type to unknow(auto detect,maybe) It goes right.

dinosaur
  • 638
  • 5
  • 14