MPMoviePlayerController on iOS5


Hi from Japan!

I now enjoy learning iOS with this nice textbook (Thank you, authors!)
after reading “Cocoa Programming for Max OS X”.

Well, today, I ran into a problem on MPMoviePlayerController on iOS5.
The movie didn’t start when I ran the code on the book.
I’ve tried everything and found a simple solution: Add one line to ‘init’ method as below:
And, now it seems to be working nicely. Hope this helps.

– Takeshi

- (id)init
    self = [super initWithNibName:@"MediaPlayerViewController" bundle:nil];

    if (self) {

        NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"Layers"
        if (moviePath) {
            NSURL *movieURL = [NSURL fileURLWithPath:moviePath];
            moviePlayer = [[MPMoviePlayerController alloc]

            // I added this line. You can try other modes, of course!
            [moviePlayer setScalingMode:MPMovieScalingModeAspectFill];

        NSString *musicPath = [[NSBundle mainBundle] pathForResource:@"Music"


Great Job!



Thank you very much

You are my savior.


hi guys. you’re more than welcome.


Alternatively just add [moviePlayer play] in the viewDidLoad method after you are done setting the frame for the MoviePlayer’s View.

But I don’t know why it doesn’t show the play controls by default.