Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

In my project I use embeded view, which has MPMoviePlayerController inside.

This movie player stops working after tapping full screen toggle - it plays 1 more second in full screen mode and then stops and turns back to the inline mode.

It happens only in portrait mode and only for iOS 7 - if I switch on full screen mode with landscape orientation and then rotate the device, it works alright.

I've found the reason - somehow navigation bar is involved. I use ECSlidingViewController in the project and set up navigation bar translucent "NO" during the initialization:

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myViewController];

navController.navigationBar.translucent = NO;

self.topViewController = navController;

If I set up navController.navigationBar.translucent = YES; the movie player works fine. But I have to have translucent = NO.

So I've tried to play with the movie players events MPMoviePlayerWillEnterFullscreenNotification and MPMoviePlayerWillExitFullscreenNotification. It's interesting that if I make navBar translucent or hide it before entering full screen mode, the video plays a little bit longer (around 3-4 seconds) but then the behavior is 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 what I can do with this are much appreciated.

UPD. This bug is gone in iOS 7.0.4

like image 486
Dmitry Khryukin Avatar asked Jan 21 '14 00:01

Dmitry Khryukin


People also ask

How do you make iPhone landscape full screen?

Swipe down from the top-right corner of your screen to open Control Center. Tap the Portrait Orientation Lock button to make sure that it's off. Turn your iPhone sideways.

What are the possible app orientation in the APK builder?

Display orientation. This refers to which side of the device is in the upward position, and can be one of four values: portrait, landscape, reverse portrait, or reverse landscape.


1 Answers

IMP:If you're using ARC I believe you need to retain the outer moviePlayer. I just assigned it to a new property myself.

I tried following two ways and its working for me.

If your using self view as entire 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 view you can work with entire fullscreen(it does not invoke the fullscreen-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];
like image 94
python Avatar answered Oct 15 '22 20:10

python