title: MPMoviewPlayerController fullscreen playback rotation with underlying UIViewController with portrait mode only (rotation disallowed)
body: <p>Hallo,</p>
  
  <p>I have a simple application, which does contain UITabBarController with two UIViewControllers. Both UIViewControllers are portrait only (no rotation allowed). One UIViewController's UIView does contain MPMoviePlayerController's view to allow video playback inside this view with possibility to make it fullscreen via controls (MPMovieControlStyleEmbedded). The code is simple and does look like ...</p>
  
  <pre><code>__moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"MOVIE_URL"]];
  __moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
  __moviePlayer.view.frame = CGRectMake( 10, 10, 300, 200 );
  __moviePlayer.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  __moviePlayer.shouldAutoplay = NO;
  [__moviePlayer prepareToPlay];  
  [self.view addSubview:__moviePlayer.view];
  </code></pre>
  
  <p>... this does work perfectly unless user switches to fullscreen playback where I want to allow rotation to allow landscape playback too. Rotation doesn't work, because UITabBarController disallows it (and both UIViewControllers too).</p>
  
  <p>So, I tried two approaches, but none of them does work as expected.</p>
  
  <p><em>1) Subclassed UITabBarController</em></p>
  
  <p>I did add property BOOL __allowRotation and if it is set to YES, I do return YES in UITabBarController's shouldAutorotateToInterfaceOrientation method.</p>
  
  <p>I'm listening for MPMoviePlayerDidEnterFullscreenNotification and MPMoviePlayerWillExitFullscreenNotification notifications to set this property to YES and NO.</p>
  
  <p>It does work, but the problem is, that when the user ends video playback in landscape, underlying view is not rotated back to portrait. The only way to rotate back to portrait is to use private API, which is no no.</p>
  
  <p><em>2) View/layer transformation</em></p>
  
  <p>I also did try to listen for MPMoviePlayerDidEnterFullscreenNotification and MPMoviePlayerWillExitFullscreenNotification notifications.</p>
  
  <p>When I receive MPMoviePlayerDidEnterFullscreenNotification, I'm starting UIDevice orientation notifications to get device orientation. I'm trying to transform MPMoviePlayerController's view layer based on current device orientation, but it's kinda immune, because it does nothing. I can assign whatever to transform property, but it does nothing.</p>
  
  <p>It does nothing is not quite correct. When I apply transformation during rotation, I can see effect of this transformation when I switch back from fullscreen to embedded video playback.</p>
  
  <p><em>3) Separate UIWindow</em></p>
  
  <p>I did not test this yet, but I've found somewhere that MPMoviePlayerController creates separate UIWindow for fullscreen playback, which should be accessible via [[UIApplication sharedApplication] windows]. This does explain why transformation is not applied during fullscreen playback.</p>
  
  <p>But I quite dislike this solution, because the UIWindow can't be identified and I do not want to use magic constants like objectAtIndex:1 or apply transformation to all UIWindows except the main one, etc.</p>
  
  <p>Beside the fact that the underlying implementation can be modified and it will stop working.</p>
  
  <p><em>Question</em></p>
  
  <p>So, the question is, how to allow MPMoviePlayerController fullscreen playback only rotation when underlying UIView (ie. UIView's UIViewController) prohibits rotation and allows portrait only?</p>