Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.
- (IBAction)playMovie {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"MOVIE001" ofType:@"mov"]];
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
// Register to receive a notification when the movie has finished playing.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {
// Use the new 3.2 style API
moviePlayer.controlStyle = MPMovieControlStyleNone;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
} else {
// Use the old 2.0 style API
moviePlayer.movieControlMode = MPMovieControlModeHidden;
[moviePlayer play];
}
}
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Play iPhone Movies in Portrait Mode with MPMoviePlayerController using Public API’s
http://iphonedevelopertips.com/video/play-movies-in-portrait-mode-with-mpmovieplayercontroller-using-public-apis.html
You can download the source code - in the bottom of the article. It looks very nice.
The answer on your question is here:
http://stackoverflow.com/questions/3019200/how-to-rotate-an-mpmovieplayercontroller
http://stackoverflow.com/questions/2852872/mpmovieplayercontroller-fullscreen-quirk-in-ipad/3026039#3026039
You will see - people proposes to make new class derived from the movie controller and add method:
- (BOOL)shouldAutorotateToIn
{
return UIInterfaceOrientationIsLa
}
Then use this class instead of the MPMoviePlayerController.
BTW, please pay attention on movieFinishedCallback - that's answer on your question how to know when the show finished (if you are still looking for it).