15

My MPMoviePlayerController crashes when I try and play any video.

This happens only on the simulator, works fine on a device.

Error is as follows:

2012-10-25 16:46:24.033 TheFasterChef[8529:14303] [MPAVController] Autoplay: Disabling autoplay for pause
2012-10-25 16:46:24.035 TheFasterChef[8529:14303] [MPAVController] Autoplay: Disabling autoplay
2012-10-25 16:46:24.172 TheFasterChef[8529:14303] [MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 1, on player: 0)
2012-10-25 16:46:24.190 TheFasterChef[8529:14303] [MPAVController] Autoplay: Enabling autoplay
2012-10-25 16:46:24.227 TheFasterChef[8529:14303] [MPAVController] Autoplay: Likely to keep up or full buffer: 0
2012-10-25 16:46:24.227 TheFasterChef[8529:14303] [MPAVController] Autoplay: Skipping autoplay, not enough buffered to keep up.
2012-10-25 16:46:24.232 TheFasterChef[8529:14303] [MPAVController] Autoplay: Enabling autoplay
2012-10-25 16:46:24.238 TheFasterChef[8529:14303] [MPCloudAssetDownloadController] Prioritization requested for media item ID: 0

My code is the bog standard method for calling MPMoviePlayerController:

In .h file:

@property (retain) MPMoviePlayerController *videoPlayer;

In .m file:

NSBundle *appBundle = [NSBundle mainBundle];
//NSString *contentURLString = [appBundle pathForResource:videoIdentifier ofType:@"mp4"];
NSString *contentURLString = [appBundle pathForResource:@"test" ofType:@".mp4"];
NSURL *contentURL = [NSURL fileURLWithPath:contentURLString];

self.videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:contentURL];
[self.videoPlayer prepareToPlay];
[self.videoPlayer.view setFrame: self.view.bounds];
[self.view addSubview:self.videoPlayer.view];
[self.videoPlayer prepareToPlay];
[self.videoPlayer play];

I have tried this snippet of code in a different view controller with the same error result.

I have tried this snippet code in a new project and it works fine.

What else could be causing this error?

The answer here did not solve it for me.

Community
  • 1
  • 1
Alan
  • 4,325
  • 3
  • 21
  • 25
  • 14
    There is no `error` in your log - its all fine. Did you activate an Exception Breakpoint within the Xcode debugger? If so, does the app also crash once that breakpoint is deactivated? – Till Oct 25 '12 at 16:02
  • Oh dear, you're right. I feel like a twat. I won't reveal how long I was flummoxed by this before resorting to stack overflow, but needless to say, sincere thanks Till. – Alan Oct 25 '12 at 16:12
  • :D - my pleasure and good luck from now on... – Till Oct 25 '12 at 16:14
  • 1
    @Till That is a really useful tip. There is some sort of bad interaction between Xcode and MPMoviePlayerController used in the Simulator. Turning off the exception breakpoint fixes it. You should turn your comment into an actual answer; I for one would like to upvote it! – matt Feb 03 '13 at 21:00
  • Agreed Matt, would happily accept! – Alan Feb 04 '13 at 09:57

4 Answers4

57

Solution: Remove the "All Exceptions" from the breakpoint tab.
This answer is from Till's comment above. I had this problem and I almost missed the answer because it is a comment. Till's answer helped me, so I hope this helps someone else like me.

exception

RawMean
  • 8,374
  • 6
  • 55
  • 82
  • 7
    I would like to enhance your answer by a little verbosity... The iOS SDK introduced this issue when iOS5 got into beta. It is not a video playback issue but is bound to the sound playback. Deep within the iOS Simlator SDK (which apparently is partially built using C++), there are exceptions used for handling certain situations. These exceptions are in no way connected to bugs or crashes but regular program flow. Unfortunately, Xcode's debugging component recognizes these exceptions as something fatal and hence stops the execution of your app on the simulator when being run in debug mode. – Till Jun 04 '13 at 22:10
  • 1
    Connected issues: [iOS 6 streaming player com.apple.coremedia.networkbuffering bug](http://stackoverflow.com/a/13973510/91282) and [What does this gdb output mean?](http://stackoverflow.com/a/8317546/91282). – Till Jun 04 '13 at 22:12
  • Brilliant answer. Saved me from a lot of trouble. Thanks! – TotoroTotoro Sep 05 '14 at 18:34
  • 5
    Removing the "All Exceptions" breakpoint is maybe not what you want. I suggest to set this breakpoint and then ctrl-click it to edit it. Then open the Exception pulldown list, and select "Objective-C" instead of "All". – Reinhard Männer Apr 28 '15 at 08:03
  • This is why SO is awesome! – elbuild May 26 '17 at 16:01
5

You've given the answer yourself. This is purely a Simulator problem. In general, the media-related API works a lot better (sometimes, only) on the device.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • @RawMean Yes it is. It *is* the answer. I've had this exact issue. There is some kind of bug in the simulator that throws an exception here, which does not happen on the device. – matt May 16 '13 at 04:10
  • You are correct about the problem, but you are not offering a solution. – RawMean May 16 '13 at 04:11
  • 2
    Yes I am. My solution is that he should regard the Simulator exception as bogus, and should test his code only on the device so as to avoid it. – matt May 16 '13 at 04:12
  • @RawMean This indeed is a correct answer, even though it comes along rather general - still everything within this answer is true and helpful. – Till Jun 04 '13 at 22:17
2

better yet, disable (rather than delete) the "All Exceptions" if you need for other things.

Sagi Mann
  • 2,967
  • 6
  • 39
  • 72
0

It seems that simulator doesn't support mp4 but mov. I got the same problem, it worked fine on simulator after converting video to mov.

Linc
  • 1,279
  • 12
  • 16