1

I present an MPMovieViewController with the following code:

NSString *path = [[NSBundle mainBundle] pathForResource:@"Tutorial" ofType:@"m4v"];

// If path is NULL (the resource does not exist) return to avoid crash
if (path == NULL)
    return;

NSURL *url = [NSURL fileURLWithPath:path];

MPMoviePlayerViewController *mpViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
mpViewController.moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
mpViewController.moviePlayer.shouldAutoplay = YES;

// NOTE: This can crash the app in the Simulator. This is a known bug
// in xcode: http://stackoverflow.com/a/8317546/472344
[self presentMoviePlayerViewControllerAnimated:mpViewController];

This works fine in iOS 4.3 and up, but I've had someone test it on a device running iOS 4.2.1 and the movie player view controller presents, but immediately dismisses itself. I can't find anything in the docs that would explain this. Does anyone have any ideas?

Darren
  • 10,091
  • 18
  • 65
  • 108

1 Answers1

1

That sounds a lot like an incompatibility of the movie content itself.

I suspect that iOS 4.2.1 device is an iPhone 3G. The 3G does not support as many codecs as the more recent models do.

The iPhone 3G on iOS4.2.1 (and below) does not support the Main Profile but only the Baseline Profile.

Long story short, the videos you are trying to play are not compatible with the device and you will need to reencode them using the Baseline Profile of H264.

Below is a compatibility vs. encoding matrix done by Apple. Even though this is entitled HTTP Streaming Encode Recommendations, it still also applies for non-streaming (progressive download) and local playback.

enter image description here

Till
  • 27,559
  • 13
  • 88
  • 122
  • Thanks, I was beginning to suspect the same thing. The funny thing is that it works on an iPod 2G running iOS 4.2.1. I'll try testing with a encoding. – Darren Aug 16 '12 at 22:44
  • In case your content is reachable via web, try to play it directly from your mobile safari browser. That would rule out any problems with your code and confirm the encoding issue. – Till Aug 16 '12 at 22:54
  • Yes, as it turns out this was the problem. – Darren Aug 17 '12 at 02:08