我正在开发一个具有三个 View 的选项卡栏应用程序 - 其中一个 View 是表格 View ,其行与我们服务器上的视频相关联。
我正在使用 MPMoviePlayerController 类来尝试提供这些服务。我的问题是,在 iPhone 上视频启动和播放都很好,但在 iPodTouch 上我得到的只是黑屏 - 没有控件,没有视频。
这是我用来启动相关视频的代码:
NSURL * url = [NSURL URLWithString:@"http://209.85.225.147/AbCoaster.mp4"];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:url];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.fullscreen = YES;
[moviePlayerController play];
您知道为什么这在一台设备上运行良好但在另一台设备上运行不佳吗?
提前致谢。
最佳答案
快速浏览了一下,看起来它应该可以工作(并且在 4.3 中也可以)。我在 Google 上快速搜索 MPMoviePlayerController iOS 4.2,发现此链接是 iOS 4.1 到 4.2 的更改日志。
http://developer.apple.com/library/ios/#releasenotes/General/iOS42APIDiffs/index.html
如果您向下滚动并查看 MPMoviePlayerController 的更改,您将看到 4.2 Apple 删除了 [MPMoviePlayerController play] 方法。必须在 4.3 中将该功能添加回库中。我会尝试将 [MPMoviePlayerController shouldAutoPlay] 设置为 true。一旦缓冲区有足够的视频缓冲,该属性就会告诉视频立即启动,以确保不间断播放。
如果这不起作用,那么您可能无法让视频自动播放。
祝你好运!
关于iphone - MPMoviePlayerController 代码在 iPhone(运行 4.3)上播放视频,但不能在 iPodTouch(运行 4.2)上播放视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6203897/