开发者

How to save video from a url to disk, also how to begin playback after some buffering?

开发者 https://www.devze.com 2022-12-22 00:40 出处:网络
First question is, given a url to an mp4 video, how can I save that file to disk?The followup to that is while its saving, can I begin playback after its buffered some of the video to disk or do I hav

First question is, given a url to an mp4 video, how can I save that file to disk? The followup to that is while its saving, can I begin playback after its buffered some of the video to disk or do I have to wait for the entire file to be written and then:

MPMoviePlayerController* theMovie=[[MPMovi开发者_如何转开发ePlayerController alloc] initWithContentURL:theURL]; 

using the path to the local file.

Thanks, Sam


The MPMoviePlayerController will start downloading the movie to it's own cache and will start playing the video as soon as enough data has been downloaded.

AFAIK there is no way to control the download and to for example save it to a known file that you specify.


1.Using NSURLDownload or NSURLConnection can implement your request.

2.play downloaded file or localfile, just like play url link

[NSURL fileURLWithPath:yourlocalpath];


There is no simple way to do this, but you could use NSURLConnection to download the file and re-serve it from a specialized HTTP server of your making running locally on the device (your server would save the file to disk and reserve up the partial download for MPMoviePlayerController to access)

0

精彩评论

暂无评论...
验证码 换一张
取 消