Take the 2-minute tour ×

I've developed an iPhone app that has been running MPMoviePlayer (pre 3.2 SDK) with no problems. I know this is a newbie question, but how do I get a movie to play in the new MPMoviePlayerViewController. I am only getting audio and wish to learn the new view controller. I've ported my whole app over to iPad and everything else works fine except for video. Could someone please show an example using the movie view controller? Any help would be appreciated.


share|improve this question
refer to devx.com/wireless/Article/44642/1954 –  Forrest Aug 2 '10 at 13:59

6 Answers 6

up vote 18 down vote accepted
NSURL* videoURL = [NSURL URLWithString:url];
MPMoviePlayerController   moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[moviePlayer prepareToPlay];
[moviePlayer play];
//For viewing partially.....
[moviePlayer.view setFrame:CGRectMake(50, 200, (self.view.frame.size.width)-100 , 400)];
moviePlayer.view.backgroundColor = [UIColor grayColor]; 
[self.view addSubview:moviePlayer.view];    
share|improve this answer
thanks ... it worked for me, –  Biranchi May 16 '10 at 17:31
it works fine for all why don't for me...it plays only audio no visuals are there –  Heena Dave Jul 7 '11 at 3:48

You need to use MPMoviePlayerViewController, not MPMoviePlayerController. Search the docs for MPMoviePlayerViewController.

share|improve this answer

Try this in your view controller:

MPMoviePlayerViewController* theMoviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL];
[self presentMoviePlayerViewControllerAnimated:theMoviePlayer];

This should get you started but check the MPMoviePlayerViewController Class Reference for detailed info.

share|improve this answer

I've struggled all over the place with this - Apple's own MoviePlayer sample code doesn't play video, only audio. It actually took me ages to figure out that it was playing audio because the sample airplane video they supply has NO AUDIO TRACK!!! (So I click the button and get absolutely nothing.)

Thanks for all the suggestions here. I finally found https://developer.apple.com/library/ios/#qa/qa2010/qa1240.html and even that is an obscure-ish fix.

This works: in initAndPlayMovie after [mp release]:

[[self.moviePlayer view] setFrame:[window bounds]];// size to fit parent view exactly
[window addSubview:[self.moviePlayer view]];

Bon voyage and happy flying :)

share|improve this answer

change this line:

MPMoviePlayerController  moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];


MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];

you need the *

share|improve this answer

I am pretty sure that its broken in simulator at present ! I get same behavior (no video but hear audio) with latest sdk and their own MPMoviePlayer sample code with Apples own video that Will play in iPad simulator using safari... So bottom line video plays on simulator-ipad inside of Safari but Not from an app using MpMoviePlayer class. Bug or feature, you decide. (I think its just broken). release notes for this version have lots of changes going on in MPMoviePlayer class...

share|improve this answer

protected by Tim Post Mar 8 '11 at 0:24


Would you like to answer one of these unanswered questions instead?
