【发布时间】:2011-11-28 14:27:10
【问题描述】:
在我将 iPhone 升级到 iOS 5.0 之前,我的代码运行良好。 MPMoviePlayerViewController 过去可以正常工作,但在 iOS 5.0 上不起作用,因此我必须将 MPMoviePlayerController 用于 iOs 5.0 及更高版本。它工作正常,但 MPMoviePlayerController 不会像以前使用 MPMoviePlayerViewController 那样自动旋转。
以下是我的代码。谁能建议我如何让 MPMoviePlayerController 代码自动旋转?
-(void)playVideo {
NSString *filePath = [appDelegate filePath:@"startup.mp4"];
if(!appDelegate.iOS5) {
// This works perfectly till iOS 4 versions. Rotates automatically
MPMoviePlayerViewController *videoController = [[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:filePath]] autorelease];
[self presentMoviePlayerViewControllerAnimated:videoController];
} else {
// This doesn't rotate automatically
NSURL *url = [NSURL fileURLWithPath:filePath];
MPMoviePlayerController* moviePlayer = [[[MPMoviePlayerController alloc] initWithContentURL:url] autorelease];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return YES;
}
【问题讨论】:
标签: iphone ios5 mpmovieplayercontroller