1

Here is my problem, I tried to use MPMoviePlayerController to play stream video, so I prepare to put the MPMoviePlayerController's view in my custom viewController set the controlStyle property to MPMovieControlStyleNone, and I provide the custom player controller, and in my init method:

_moviePlayer = [[MPMoviePlayerController alloc] init];  
_moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;  
_moviePlayer.shouldAutoplay = YES;  
_moviePlayer.scalingMode = MPMovieScalingModeAspectFit;  
_moviePlayer.controlStyle = MPMovieControlStyleNone;

and I put custom player controll on the moviePlayer, when I prepare to play, I get the real URL from network and the let moviePlayer to play:

_moviePlayer.contentURL = [NSURL URLWithString:url];  
[_moviePlayer prepareToPlay];

then I register the related notification to report what happening
I provide the simple seek method seek and just call the moviePlayer's seek method, I found when the network latency is high and I try to seek, after some times, the app crashed. and the following the call stack:

`0 CoreFoundation 0x381bd8a7 __exceptionPreprocess + 186  
1 libobjc.A.dylib 0x334ee259 objc_exception_throw + 32  
2 AVFoundation 0x37afb0dd -[AVPlayerItem _attachToPlayer:forImmediateEnqueueing:shouldAppendItem:] + 320   
3 AVFoundation 0x37af1edb -[AVPlayer _insertPlaybackItemOfItem:inPlayerQueueAfterPlaybackItemOfItem:] + 42  
4 AVFoundation 0x37af2c37 __block_global_0 + 1038  
5 libdispatch.dylib 0x34ae5c59 _dispatch_call_block_and_release + 12  
6 libdispatch.dylib 0x34ae7ee7 _dispatch_main_queue_callback_4CF$VARIANT$mp + 194
7 CoreFoundation  0x381902ad __CFRunLoopRun + 1268  
8   CoreFoundation  0x381134a5 CFRunLoopRunSpecific + 300  
9   CoreFoundation  0x3811336d CFRunLoopRunInMode + 104  
10  GraphicsServices0x365f6439 GSEventRunModal + 136  
11  UIKit 0x30fc4cd5 UIApplicationMain + 1080  
12  Player 0x000284dd main + 152  
13  Player 0x0001abb8 start + 40  
"Exception Name" = NSInvalidArgumentException  
"Exception Reason" = "An AVPlayerItem cannot be associated with more than one instance of AVPlayer`  

See the expection reason, I guess may I init muti instance of AVPlayer, but I only have one MPMoviePlayerController, and can any one point me the direction? Thanks

nzs
  • 3,252
  • 17
  • 22
gaobinleo
  • 11
  • 3

1 Answers1

1

You haven't shown any of your code so it's impossible to make sense of your question. The problem is something you are doing wrong, so you must show exactly what you are doing if you want help.

However, please note that Apple may be already helping you. The error message you're getting is very explicit:

"Exception Reason" = "An AVPlayerItem cannot be associated with more than one instance of AVPlayer"

That could be a huge clue. It could be useful to think about how you might be violating that rule.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • hi, I add the code, and I want to know the relationship between the AVPlayerItem and MPMoviePlayerController, thanks for your answer. – gaobinleo Apr 07 '13 at 05:33