Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Caching videos to disk after successful preload by MPMoviePlayerController

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.

like image 404
Nathan de Vries Avatar asked Jun 01 '09 10:06

Nathan de Vries


2 Answers

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.

like image 62
gene tsai Avatar answered Sep 28 '22 09:09

gene tsai


I haven't tested this, but it may be possible to override [NSURLCache sharedURLCache] with a custom disk-only cache implementation. If MPMoviePlayerController uses NSURLRequest, it could work.

like image 31
Nathan de Vries Avatar answered Sep 28 '22 11:09

Nathan de Vries