MPMoviePlayerController成功预加载后,将视频缓存到磁盘 [英] Caching videos to disk after successful preload by MPMoviePlayerController

查看:289
本文介绍了MPMoviePlayerController成功预加载后,将视频缓存到磁盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用MPMoviePlayerController的 initWithContentURL:启动视频后,是否可以缓存下载的视频,以便下次播放视频时可以通过本地文件加载:// URI?我知道可以自己下载并然后启动电影播放器​​,但是我想利用播放器在完成预加载之前启动的能力。

解决方案

一招,就是开始下载到磁盘 - (使用atomic:YES),等待10秒,然后将电影播放器​​指向本地磁盘路径。它会在播放不完整的文件时下载。



下次,只需检查文件是否存在。



<我在WIFI连接上运行得相当好,但在3G上有各种各样的崩溃。



更糟糕的是,本地文件不完整的问题。让我知道它是否值得。


After launching a video using MPMoviePlayerController's initWithContentURL:, is it possible to cache the downloaded video so that the next time the video is played it can be loaded via a local file:// URI? I understand that it's possible to do my own downloading and then launch the movie player, however I would like to take advantage of the player's ability to start prior to completion of preload.

解决方案

one trick, is to start the download to disk - (using atomic : YES), wait 10 seconds, and point the movie player to the local disk path. it will "download" while playing the incomplete file.

next time, just check if the file exists first.

I got this working pretty well on WIFI connections, but on 3G there were all kinds of crashyness.

worse, there were issues with incomplete local files. let me know if it is worth it.

这篇关于MPMoviePlayerController成功预加载后,将视频缓存到磁盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆