如何在 iOS4 上检测电影预加载/失败?
在 3.0 中,我可以注册 MPMoviePlayerContentPreloadDidFinishNotification 并根据是否存在错误对象来检测电影是否已预加载或失败。谁能告诉我这两种情况在 iOS4 上的等效情况吗?
[更新:回复此处的第一条评论,因为最大评论长度太短。]
如果您在 iOS4 上成功播放电影,您会得到:
MPMoviePlayerContentPreloadDidFinishNotification
,没有错误对象(已弃用)MPMoviePlayerLoadStateDidChangeNotification
和player.loadState=MPMovieLoadStatePlayable
MPMoviePlayerPlaybackDidFinishNotification
和player.loadState=MPMovieLoadStatePlaythroughOK
如果失败(对于实例,因为 URL 不正确),您会得到:
MPMoviePlayerPlaybackDidFinishNotification
loadState=MPMovieLoadStateUnknown
就这样。没有像 3.0 中那样带有错误对象的 MPMoviePlayerContentPreloadDidFinishNotification
,也没有 MPMoviePlayerLoadStateDidChangeNotification
。那么,这是检测加载失败以检查 MPMoviePlayerPlaybackDidFinishNotification
中 MPMovieLoadStateUnknown
的播放器的唯一方法吗?
至少可以说,这似乎违反直觉。
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
andplayer.loadState=MPMovieLoadStatePlayable
MPMoviePlayerPlaybackDidFinishNotification
andplayer.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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
注册
MPMoviePlayerLoadStateDidChangeNotification
通知,然后检查MPMoviePlayerController
的loadState
属性。来源:ADC 开发人员文档
Register for the
MPMoviePlayerLoadStateDidChangeNotification
notification, and then check theloadState
property of theMPMoviePlayerController
.Source: ADC Developer Documentation