【问题标题】:MPMoviePlayerViewController dismissing itself immediately in iOS 4.2MPMoviePlayerViewController 在 iOS 4.2 中立即关闭自身
【发布时间】:2012-08-16 18:17:35
【问题描述】:

我展示了一个带有以下代码的 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 的设备上对其进行了测试,并且电影播放器​​视图控制器出现,但立即自行关闭。我在文档中找不到任何可以解释这一点的东西。有人有什么想法吗?

【问题讨论】:

    标签: ios mpmovieplayercontroller ios-4.2 ios4 mpmovieplayer


    【解决方案1】:

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

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

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

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

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

    【讨论】:

    • 谢谢,我开始怀疑同样的事情。有趣的是,它可以在运行 iOS 4.2.1 的 iPod 2G 上运行。我将尝试使用编码进行测试。
    • 如果您的内容可以通过网络访问,请尝试直接从您的移动 Safari 浏览器播放。这将排除您的代码的任何问题并确认编码问题。
    • 是的,事实证明这是问题所在。
    猜你喜欢
    • 1970-01-01
    • 2020-03-02
    • 2021-07-22
    • 1970-01-01
    • 1970-01-01
    • 2011-07-02
    • 2014-09-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多