这似乎是rotate an MPMoviePlayerController to landscape is to use an MPMoviePlayerViewController 的最佳(唯一?)方式。
我目前正在修改一个开源游戏,遗憾的是,它没有根UIViewController设置。有没有办法只使用MPMoviePlayerController设置方向,或者我是否需要将它吸收并将根UIViewController入侵到此应用程序中?
编辑:为了回应Shivan Raptor,游戏是Canabalt:https://github.com/ericjohnson/canabalt-ios。我正在实例化一个MPMoviePlayerController,如下所示:
self.moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:self.videoTempFilePath];
self.moviePlayerController.repeatMode = MPMovieRepeatModeNone;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackComplete:)
name:MPMoviePlayerDidExitFullscreenNotification
object:self.moviePlayerController];
[glView addSubview:self.moviePlayerController.view];
// MUST SET THIS HERE AFTER WE ADD AS SUBVIEW
self.moviePlayerController.fullscreen = YES;
[self.moviePlayerController play];
电影以肖像方式播放并保持锁定,但我想在风景中播放。
答案 0 :(得分:0)
我创建了一个根UIViewController并使MPMoviePlayerViewController成为它的子节点。这创造了预期的效果。
答案 1 :(得分:0)
我认为这可能会有所帮助。
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
[self.view setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
return true;
}
else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
[self.view setTransform:CGAffineTransformMakeRotation(M_PI * 2)];
return true;
}
else if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {
[self.view setTransform:CGAffineTransformIdentity];
return true;
}
else return false;
}