1
我的代碼工作正常,直到我將iPhone升級到iOS 5.0。 MPMoviePlayerViewController用於正常工作,但它不適用於iOS 5.0,因此我必須爲iOs 5.0和更高版本使用MPMoviePlayerController。它工作正常,但MPMoviePlayerController不像MPMoviePlayerViewController那樣自動旋轉。iPhone:MPMoviePlayerController不在iOS 5.0上旋轉
以下是我的代碼。任何人都可以請建議我如何使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;
}
必須有別的東西。我想知道爲什麼它旋轉MPMoviePlayerViewController(iOS4.0和更早版本),但不是MPMoviePlayerController(iOS5和更高版本)? – applefreak
嗨AppleDevelop,我也面臨着同樣的問題,在我的情況下,我把我的viewController放在導航控制器上,當視頻處於全屏模式時,didRotate沒有被調用,因爲在正常模式下該方法被調用。如果你已經解決了你的問題plz幫助我... – Dinakar
諾佩哥們。它不工作!你有周圍嗎? – applefreak