我正在使用 MPMoviePlayerController 播放电影。电影以纵向模式开始(因为这是该应用程序使用的唯一模式)并且即使设备旋转也保持在那里。我从未明确设置 shouldAutoRotateetc。响应横向和纵向的功能,因为我不想调整我的 View 大小。有没有办法让视频响应纵向和横向旋转?任何帮助将不胜感激。
仅供引用:这是我的代码
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"TestMovie" ofType:@"m4v"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
//Listen so we can clean up after the movie is over
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackComplete:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController];
[self.view addSubview:moviePlayerController.view];
[moviePlayerController setFullscreen:YES animated:YES];
[moviePlayerController play];
最佳答案
嗯。好的。在我被难住后半小时想通了。
现在显然有一个 MPMoviePlayerViewController 可以处理所有这些。这是我新更新的代码:
MPMoviePlayerViewController *moviePlayerView = [[[MPMoviePlayerViewController alloc] initWithContentURL:videoURL] autorelease];
[self presentMoviePlayerViewControllerAnimated:moviePlayerView];
这将允许它响应旋转事件等。很好!
关于iphone - 我的 iPhone 视频只能以纵向模式播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4911074/