ios - MPMoviePlayerViewController 在 iOS 4.2 中立即自行解雇

标签 ios mpmovieplayercontroller ios-4.2 ios4 mpmovieplayer

我使用以下代码呈现一个 MPMovieViewController:

NSString *path = [[NSBundle mainBundle] pathForResource:@"Tutorial" ofType:@"m4v"];

// If path is NULL (the resource does not exist) return to avoid crash
if (path == NULL)
    return;

NSURL *url = [NSURL fileURLWithPath:path];

MPMoviePlayerViewController *mpViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
mpViewController.moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
mpViewController.moviePlayer.shouldAutoplay = YES;

// NOTE: This can crash the app in the Simulator. This is a known bug
// in xcode: http://stackoverflow.com/a/8317546/472344
[self presentMoviePlayerViewControllerAnimated:mpViewController];

这在 iOS 4.3 及更高版本中运行良好,但我已经让某人在运行 iOS 4.2.1 的设备上对其进行了测试,并且电影播放器​​ View Controller 出现,但立即自行消失。我在文档中找不到任何可以解释这一点的内容。有人有什么想法吗?

最佳答案

这听起来很像是电影内容本身的不兼容。

我怀疑 iOS 4.2.1 设备是 iPhone 3G。 3G 支持的编解码器不如最新型号那么多。

iOS4.2.1(及以下版本)的 iPhone 3G 不支持 Main Profile,仅支持 Baseline Profile。

长话短说,您尝试播放的视频与设备不兼容,您需要使用 H264 的基线配置文件对其重新编码。

下面是 Apple 完成的兼容性与编码矩阵。尽管这标题为 HTTP 流媒体编码建议,但它仍然适用于非流媒体(渐进式下载)和本地播放。

enter image description here

关于ios - MPMoviePlayerViewController 在 iOS 4.2 中立即自行解雇,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11993107/

相关文章:

ios - NSString URL解码?

ios - 如何检测选择了哪个事件以及如何检查消息是否已发送?

iphone - MPMoviePlayerController - 控件未对齐

java - 使用 GMImagePickerController 播放视频时黑屏

ios - 我应该为每个 ViewController Swift 创建一个新的 managedObjectContext

ios - 我应该在类之间共享 UIAlertView 吗?

ios - 仅支持纵向应用程序中视频播放器 View Controller 的所有方向

objective-c - UITextfield.text 返回 null

ios - NSOperationQueue 和并发操作

iphone - 从 UITextField 退格一个加号 (+) - 奇怪的错误