Hi
I need to show a fullscreen video with the normal modal view controller display animation when the user clicks a button. I tried several ways of doing this:
MPMoviePlayerViewController *viewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:pathToVideoFile]];
//[self presentMoviePlayerViewControllerAnimated:viewController];
[self presentModalViewController:viewController animated:YES];
[viewController release];
The animation of the presentMoviePlayerViewControllerAnimated
method is different to the normal modal animation since it moves the existing view controller in and out of the screen instead of the video view controller. When I use the presentModalViewController
method, the video screen comes up (the way it should), but when I press the Done button to hide it, the previous screen comes up, instead of the video screen moving down and out of the screen.
Then I tried using MPMoviePlayerController within a normal UIViewController and displaying this using the presentModalViewController method (which does the show and hide animations properly), using the following code:
- (void)loadView {
self.wantsFullScreenLayout = YES;
UIView *baseView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
self.view = baseView;
[baseView release];
player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:pathToVideoFile]];
player.fullscreen = YES;
player.controlStyle = MPMovieControlStyleFullscreen;
player.view.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:player.view];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerDoneButtonClicked:) name:@"MPMoviePlayerPlaybackDidFinishNotification" object:player];
}
But now, if I press one of the previous/next buttons, the movie player view just disappears.
Are all these the normal behavior of MPMoviePlayerController and MPMoviePlayerViewController, or am I doing something wrong here? Is there a way to disable the previous/next buttons and what are they supposed to do in the first place, given that only a single video url can be set in the player?