Hi All,
I am trying to launch a movie from within a subview of a toolbar view. The movie plays but the problem is that toolbar floats on top of the movie. I believe the MPMoviePlayerViewController is supposed to take care of this for us because it opens as a modal view. But I am not sure why this is case for me...
Any help to this novice programmer will be appreciated.
Thank you. Best regards,
-(IBAction)playMedia:(id)sender {
NSString *movieFile; movieFile = [[NSBundle mainBundle] pathForResource:@"myMovie" ofType:@"mp4"];
MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:movieFile]];
mp.moviePlayer.scalingMode = MPMovieScalingModeFill; [self presentModalViewController:mp animated:YES]; [self shouldAutorotateToInterfaceOrientation:YES]; [self.view addSubview:mp.view];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:[mp moviePlayer]];
[mp.moviePlayer play]; }
- (void)moviePlayBackDidFinish:(NSNotification*)notification {
MPMoviePlayerViewController *moviePlayer = [notification object]; [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
[moviePlayer.view removeFromSuperview];
[moviePlayer release]; }