MPMoviePlayerController stops working in full screen mode // portrait orientation // iOS 7

In my project, I use the built-in view, which has an MPMoviePlayerController inside.

This player stops working after pressing full-screen switching - it plays another 1 second in full-screen mode, and then it stops and returns to the built-in mode.

This happens only in portrait mode and only for iOS 7 - if I turn on full-screen mode with landscape orientation and then turn the device around, it works fine.

I found the reason - somehow the navigation bar works. I use ECSlidingViewController in the project and set up the translucent “NO” navigation bar during initialization:

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myViewController]; navController.navigationBar.translucent = NO; self.topViewController = navController; 

If I configured navController.navigationBar.translucent = YES; The movie player works great. But I have to have translucent = NO.

So, I tried to play with events in the MPMoviePlayerWillEnterFullscreenNotification and MPMoviePlayerWillExitFullscreenNotification films. Interestingly, if I make navBar translucent or hide it before entering full-screen mode, the video plays a little longer (about 3-4 seconds), but then the behavior will be the same.

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerWillEnterFullScreen:) name:MPMoviePlayerWillEnterFullscreenNotification object:nil]; -(void)moviePlayerWillEnterFullScreen:(id)sender{ [self.navigationController setNavigationBarHidden:YES animated:NO]; OR self.navigationController.navigationBar.translucent = YES; } 

Any ideas that I can do with this are greatly appreciated.

UPD This error disappeared in iOS 7.0.4

+6
source share
1 answer

IMP: If you use ARC, I believe that you need to save the external moviePlayer. I just assigned it to a new property.

I tried to follow two paths and work for me.

If you use your own view as a full screen.

 NSURL *url = [[NSBundle mainBundle] URLForResource:@"Robot" withExtension:@"m4v"]; moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url]; moviePlayer.controlStyle = MPMovieControlStyleFullscreen; moviePlayer.view.transform = CGAffineTransformConcat(moviePlayer.view.transform, CGAffineTransformMakeRotation(M_PI_2)); [moviePlayer.view setFrame: self.view.bounds]; [self.view addSubview: moviePlayer.view]; [moviePlayer play]; 

And without using self-viewing, you can work with everything full-screen (it does not call the full-screen property)

 NSURL *url = [[NSBundle mainBundle] URLForResource:@"Robot" withExtension:@"m4v"]; moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url]; moviePlayer.controlStyle = MPMovieControlStyleFullscreen; moviePlayer.view.transform = CGAffineTransformConcat(moviePlayer.view.transform, CGAffineTransformMakeRotation(M_PI_2)); UIWindow *backgroundWindow = [[UIApplication sharedApplication] keyWindow]; [moviePlayer.view setFrame:backgroundWindow.frame]; [backgroundWindow addSubview:moviePlayer.view]; [moviePlayer play]; 
+3
source

All Articles