Luke
Luke

Reputation: 7210

Why does MPMoviePlayerController work in the simulator, but not the device?

I'm having trouble getting MPMoviePlayerController to work on the device. It runs fine in simulator, playing a five-second video and then sending the appropriate callback (myMovieFinishedCallback:) to the view controller. When it runs on the device, the movie never shows up, even though I can trace through [player play] with no problems. myMovieFinishedCallback: is never called, and there are no errors. All the right resources are being copied. Any idea what's going on?

Here's the code I use to create and use the player,

Update: I've switched over to using MPMoviePlayerViewController. On the device the movie still does not play, I just get the spinning progress wheel indefinitely. The controls also flash briefly even though I've set the player to MPMovieControlStyleNone - anybody know how I can fix this? The movie is five seconds and about 1.5 MB if that makes any difference.

Update: Other movie files work, but I can't figure out how to make mine work. I've tried it as a .mov and a .mp4 and the settings seem to be right. Any idea what would cause the MPMoviePlayer to show a progress wheel forever on the device only?

- (void) playMovie
{
    NSString *url = [[NSBundle mainBundle] 
                     pathForResource:@"myMovie" 
                     ofType:@"mp4"];

MPMoviePlayerViewController *playerViewController = 
[[MPMoviePlayerViewController alloc] 
 initWithContentURL:[NSURL fileURLWithPath:url]];

playerViewController.moviePlayer.controlStyle = MPMovieControlStyleNone;
playerViewController.moviePlayer.scalingMode = MPMovieScalingModeFill;

[[NSNotificationCenter defaultCenter] 
 addObserver:self
 selector:@selector(myMovieFinishedCallback:)
 name:MPMoviePlayerPlaybackDidFinishNotification
 object:[playerViewController moviePlayer]];

playerViewController.view.frame = movieView.frame;

[movieView addSubview:playerViewController.view];

//---play movie---
MPMoviePlayerController *player = [playerViewController moviePlayer];
[player play];
}   

Upvotes: 2

Views: 3884

Answers (1)

Matt Long
Matt Long

Reputation: 24466

Your code works fine for me, so there are two possibilities that come to mind (there may be others):

  1. You movieView has not been properly initialized or has not had its frame set so that it's visible.
  2. The video format of the video you're displaying isn't supported on the device.

I would try using a different video. Maybe one you can confirm you've played on the device before. Here's the little demo project I threw together: http://www.cimgf.com/files/PlayMovie.zip

Upvotes: 5

Related Questions