1

i am developing an app with the implementation of MPMoviePlayerViewController. there is a uitableview with links of videos that will play in it but problem is my first video plays well i tap done from player it came back then i tap on second video it plays but when i tap done it shows this: "attempt to dismiss modal view controller whose view does not currently appear." and screen goes black app doesnt terminate but just a black screen. i will show you my code.

.m file

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    player = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:[[rssOutputData objectAtIndex:indexPath.row]xmlvideo]]];
    [player.moviePlayer prepareToPlay];
    [player.view setFrame: self.view.bounds];
    [self presentMoviePlayerViewControllerAnimated:player];
    [self.view addSubview: player.view];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MPMoviePlayerDidExitFullscreen:) name:MPMoviePlayerDidExitFullscreenNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MPMoviePlayerDidExitFullscreen:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
    [player.moviePlayer play];
}
- (void)MPMoviePlayerDidExitFullscreen:(NSNotification *)notification{    
    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerDidExitFullscreenNotification object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
    [player.moviePlayer stop];
    [player.moviePlayer.view removeFromSuperview];
}
user2966615
  • 373
  • 4
  • 16
  • does it works if you remove this: [self presentMoviePlayerViewControllerAnimated:player]; ? – iOSfleer Mar 19 '15 at 12:39
  • yes it is working but it is loading inside my uinavigation and status bar is showing under the navigation bar. i guess it is loading player inside current view! – user2966615 Mar 19 '15 at 12:43
  • if you call presentMovie... you need to call dismissMovie... see here: http://stackoverflow.com/questions/13420564/how-to-stop-mpmovieplayerviewcontrollers-automatic-dismiss-on-movieplaybackdidf – iOSfleer Mar 19 '15 at 12:55

0 Answers0