Reputation: 229
I have a set or URLs, each points to a mp4 video file.
I have a newsfeed-like timeline for these video files (like Instagram videos). User can scroll up and down to browse each video. To make the video-loading faster, I'd like to preload the next few video files before the user scroll down to them. When the user actually scroll to those files, it will start playing without downloading again from network.
The files will be played in AVQueuePlayer.
Is there a way to do this? Thanks guys!
Upvotes: 3
Views: 1078
Reputation: 10954
I don't know of a way to ask AVQueuePlayer to buffer in advance.
You can create a proxy between AVPlayer and the web. This will allow you to keep track of what AVPlayer has loaded, so you can predictively download and cache upcoming media files, so they are ready when AVPlayer requests them. The cleanest way is to register a custom NSURLProtocol (beware that this does not work in the iOS simulator). You can also run a server on-device such as CocoaHTTPServer.
Upvotes: 3