开发者

iPhone Movie Rotation For Only Subview

I am working on an app that disallows rotation unless a movie is playing. I have the app rotated just fine, but the issue comes about when I try to view the movie.

The simulator is forced to rotate, but the movie does not. An example of this is below:

iPhone Movie Rotation For Only Subview

I can't figure out how to rotate the movie too. I am looking to rotate only the subview. My code is below:

MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:finalURL]];
if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {  
                // Use the 3.2 style API  
                moviePlayer.controlStyle = MPMovieControlStyleDefault;  
                moviePlayer.shouldAutoplay = YES;  
                [self.view addSubview:moviePlayer.view];  
                [moviePlayer setFullscreen:YES animated:YES];
             [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];

             // Rotate the view for landscape playback
             [[moviePlayer view] setBounds:CGRectMake(0, 0, 480, 320)];
             [[moviePlayer view] setCenter:CGPointMake(160, 240)];
             [[moviePlayer view] setTransform:CGAffineTransformMakeRotation(M_PI / 2)]; 

   开发者_运维知识库          // Set frame of movieplayer
             [[moviePlayer view] setFrame:CGRectMake(0, 0, 480, 320)];  

            } else {  
                // Use the 2.0 style API  
                moviePlayer.movieControlMode = MPMovieControlModeHidden;  
                [moviePlayer play];  
            } 
}

EDIT: I tried [moviePlayer setOrientation UIInterfaceOrientationLandscapeRight]; but the complier gives me an error and nothing happens


Are you using the MPMoviePlayerController?

Try the MPMoviePlayerViewController. That class is a UIViewController and should handle the rotation on it self.

You get the MPMoviePlayerController from the view controller by just calling the method [moviePlayerViewController moviePlayer];

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜