OGeek|极客世界-中国程序员成长平台

标题: iphone - MPMoviePlayerViewController 在 5.1 下不能横向播放 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 12:05
标题: iphone - MPMoviePlayerViewController 在 5.1 下不能横向播放

在 5.1 中是否有任何更改会影响 MPMoviePlayerViewController 在设备方向方面的工作方式?

我今天开始收到来自用户的报告,称视频只能以纵向模式播放。我发现他们使用的是 5.1,我迅速升级了一个设备来重现这种情况。我的代码没有改变并且在 4.x、5.0 和 5.01 中完美运行。

我的应用程序中的所有 View 都以纵向模式显示,除非用户单击视频,否则电影播放器​​会占据整个屏幕并以横向模式启动。该应用使用 5.0 SDK 但面向 4.0。这是我用来显示视频的代码:

VideoPlayer *vp = [[VideoPlayer alloc] initWithContentURL:movieURL];
vp.moviePlayer.movieSourceType = src;
vp.moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
vp.moviePlayer.shouldAutoplay = TRUE;
[self presentMoviePlayerViewControllerAnimated:vp];

VideoPlayerMPMoviePlayerViewController 的子类,其中 shouldAutorotateToInterfaceOrientation 被覆盖,如下所示:

- (BOOL)shouldAutorotateToInterfaceOrientationUIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIDeviceOrientationLandscapeLeft);
}

整个互联网甚至 Apple 都推荐这种模式。我不明白为什么它不能在 iOS 5.1 下运行,或者为什么没有更多人提示这个。

任何帮助将不胜感激。



Best Answer-推荐答案


我也遇到了同样的问题——我在 opengl subview 上播放电影,(我在横向模式下制作交互式电子书,所以需要我的电影——(在 uiview 中)也可以横向播放)

我通过以下方式纠正了这个问题: 将打开的 glview 子类化为 *viewcontroller,然后将该 *viewcontroller 链接到窗口

所以在使用 cocos2d 时,我现在可以以正确的方向使用所有 uikit。 将所有 uikit View 发送到我的子类 opengl View 。 (同时确保添加我的应用程序委托(delegate)并检查 plist 中是否说明了方向。)

"#if GAME_AUTOROTATION == kGameAutorotationUIViewController
    [director setDeviceOrientation:kCCDeviceOrientationPortrait];
"#else
    [director setDeviceOrientation:kCCDeviceOrientationLandscapeRight];
"#endif

希望这对某人有所帮助 我在 cocos2d 上很新,所以花了一段时间才弄清楚我做错了什么。

关于iphone - MPMoviePlayerViewController 在 5.1 下不能横向播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9627857/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4