6
votes

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

1
Sounds as if there was some kind of category (pseudo override) trickery on the navigation bar going on. If that is the case, make sure you disable that whenever using the player as its interface does in fact rely on UINavigationBar for the upper part. Categories on that class as well swizzles do leave a mess behind if not disabled.Till
thanks @Till I've checked the project - no categories or other navBar customizations.Dmitry Khryukin
That also includes no drawRect: code for UINavigationBar, correct?Till
@Till correct. have done search by "drawRect:" - nothing connected with UINavigationBar (only UIScrollView+SVPullToRefresh and MDProgressHUD)Dmitry Khryukin
Whatever your problem is, it's not in the code here. In a sample app with ECSlidingViewController and UINavigtionBar, I can play full-screen video in both orientations fine regardless of the orientation or navigation bar translucency. Can you make a sample app that reproduces the issue?Aaron Brager

1 Answers

3
votes

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];