I have a problem with MPMoviePlayerViewController: if the controller cannot find the movie at the specified URL, it displays a white screen and I cannot close it.
This is how I launch the movie player:
- (void) playVideo:(NSString*)path { NSURL* url = [NSURL URLWithString:path]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil]; double osversion = [[[UIDevice currentDevice] systemVersion] doubleValue]; if (osversion >= 3.2) { mplayerVC = [[MPMoviePlayerViewController alloc] initWithContentURL:url]; if (mplayerVC) { mplayerVC.moviePlayer.movieSourceType = MPMovieSourceTypeFile; [mplayerVC.moviePlayer play]; mplayerVC.moviePlayer.shouldAutoplay = TRUE; [self presentMoviePlayerViewControllerAnimated:mplayerVC];
and the moviePlayBackDidFinish method looks like this:
- (void) moviePlayBackDidFinish:(NSNotification*)notification { [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil]; NSError* error = [[notification userInfo] valueForKey:@"error"]; if (error != nil) {
A white screen appears only if the URL is incorrect
source share