Caching mp4 video from server for use with avplayer

I have a list of videos in my iOS app that I am retrieving from my API. The list contains video nodes with the url of the mp4 video file on the server, and as the user scrolls from one video to another, the next video starts and the previous video is paused. This all works well, but I need a way to cache the mp4 videos to disk, such that when the user tries to search, I first try to use the chunk they are looking for from their disk cache, and if it is not already cached, I start downloading the chunk from the network, and the chunks will then be cached to disk during playback. I also need a way to pre-cache the next videos, for example, if the user starts playing the first video, I need to be able to start caching the second video, so,when the second video starts playing, it does it from the cache, up to the point where the video is cached, and then fade into the selection from the server (and of course, cache the responses). How should I do it?

+3


source to share


1 answer


There is no automated way to do this built into the framework. You will be using background NSURLSessions with load tasks and delegate methods.



You can track the progress of the download, access temporary files as they download, pause, resume, and cancel them.

0


source







All Articles