如何在 iOS4 上检测电影预加载/失败?

发布于 2024-09-18 06:08:39 字数 1015 浏览 2 评论 0原文

在 3.0 中,我可以注册 MPMoviePlayerContentPreloadDidFinishNotification 并根据是否存在错误对象来检测电影是否已预加载或失败。谁能告诉我这两种情况在 iOS4 上的等效情况吗?

[更新:回复此处的第一条评论,因为最大评论长度太短。]

如果您在 iOS4 上成功播放电影,您会得到:

  • MPMoviePlayerContentPreloadDidFinishNotification,没有错误对象(已弃用)
  • MPMoviePlayerLoadStateDidChangeNotificationplayer.loadState=MPMovieLoadStatePlayable
  • MPMoviePlayerPlaybackDidFinishNotificationplayer.loadState=MPMovieLoadStatePlaythroughOK

如果失败(对于实例,因为 URL 不正确),您会得到:

  • MPMoviePlayerPlaybackDidFinishNotification loadState=MPMovieLoadStateUnknown

就这样。没有像 3.0 中那样带有错误对象的 MPMoviePlayerContentPreloadDidFinishNotification,也没有 MPMoviePlayerLoadStateDidChangeNotification。那么,这是检测加载失败以检查 MPMoviePlayerPlaybackDidFinishNotificationMPMovieLoadStateUnknown 的播放器的唯一方法吗?

至少可以说,这似乎违反直觉。

In 3.0, I could register for MPMoviePlayerContentPreloadDidFinishNotification and detect if the movie preloaded or failed, depending on whether there was an error object. Can anyone tell me the equivalent of the two cases for iOS4?

[Update: Responding to the first comment here because the max comment length is too short.]

If you successfully play a movie on iOS4, you get:

  • MPMoviePlayerContentPreloadDidFinishNotification with no error object (deprecated)
  • MPMoviePlayerLoadStateDidChangeNotification and player.loadState=MPMovieLoadStatePlayable
  • MPMoviePlayerPlaybackDidFinishNotification and player.loadState=MPMovieLoadStatePlaythroughOK

If it fails (for instance because of an incorrect URL), you get:

  • MPMoviePlayerPlaybackDidFinishNotification loadState=MPMovieLoadStateUnknown

And that's it. No MPMoviePlayerContentPreloadDidFinishNotification with an error object like in 3.0, no MPMoviePlayerLoadStateDidChangeNotification. So is the only way to detect a failed load to inspect the player.loadState for MPMovieLoadStateUnknown in MPMoviePlayerPlaybackDidFinishNotification?

It seems counterintuitive, to say the least.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白日梦 2024-09-25 06:08:39

注册 MPMoviePlayerLoadStateDidChangeNotification 通知,然后检查 MPMoviePlayerControllerloadState 属性。

来源:ADC 开发人员文档

Register for the MPMoviePlayerLoadStateDidChangeNotification notification, and then check the loadState property of the MPMoviePlayerController.

Source: ADC Developer Documentation

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文