Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top