MPMoviePlayerController - 加载电影时捕获网络错误

发布于 2024-10-02 12:41:35 字数 664 浏览 0 评论 0原文

有没有办法捕获异常(特别是网络错误 /没有可用的连接)当使用 MPMoviePlayerController 时?

我特别担心的是,一旦使用 initWithURL: 初始化播放器实例,您就无法知道电影加载是否由于某种原因失败。

我已经查看了可用的文档并意识到我可以获得 通过问题来通知 loadState 更改

moviePlayerLoadStateChanged:(NSNotification*)notification.

是可用的 loadState 常量不适合错误处理:(

MPMovieLoadStateUnknown
MPMovieLoadStatePlayable
MPMovieLoadStatePlaythroughOK
MPMovieLoadStateStalled

如果您想知道,MPMovieLoadStateStalled 由于某种原因在网络错误期间不会调用它?)

有一个已弃用的 MPMoviePlayerContentPreloadDidFinishNotification 提供了一个带有“error”键的 userInfo 字典,但对于 iOS 3.2 及更高版本没有任何内容。

任何帮助将非常感激。

Is there a way of catching exceptions (particularly for network errors
/ no connection available) when using a MPMoviePlayerController?

I am particularly concerned that once an instance of the player is initialised with initWithURL: you have no way of knowing whether the movie load has failed for some reason.

I have reviewed the available documentation and realise I can get a
notification for loadState changes through

moviePlayerLoadStateChanged:(NSNotification*)notification.

Problem is the loadState constants available don't cater for error handling:

MPMovieLoadStateUnknown
MPMovieLoadStatePlayable
MPMovieLoadStatePlaythroughOK
MPMovieLoadStateStalled

(in case you are wondering, MPMovieLoadStateStalled this doesn't get called during network errors for some reason?)

There's a deprecated MPMoviePlayerContentPreloadDidFinishNotification that provides a userInfo dictionary with an "error" key but nothing for iOS 3.2 and above.

Any help would be very much appreciated.

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

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

发布评论

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

评论(1

南渊 2024-10-09 12:41:35

最后,我通过订阅 MPMoviePlayerPlaybackDidFinishNotification 并观察 MPMovieFinishReasonPlaybackError 来排序。

更多详细信息请参见https://developer.apple.com/library/ios/documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006953-CH3-SW17

In the end I got this sorted by subscribing to MPMoviePlayerPlaybackDidFinishNotification and watching for MPMovieFinishReasonPlaybackError.

More details here https://developer.apple.com/library/ios/documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006953-CH3-SW17

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