Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resume AVAssetDownloadTask after restarting app

Tags:

ios

I am implementing HLS downloader using AVAssetDownloadTask. I can't find a way to resume download if I restart the application in middle of download. The download always starts from beginning on app restart. I cannot find any mention of resuming downloads in the documentation of AVAssetDownloadTask. Let me know if anyone has successfully been able to resume download using AVAssetDownloadTask. Thanks

like image 740
dev Avatar asked Oct 28 '16 12:10

dev


1 Answers

Found this PDF titled "Offline Playback with FairPlay Streaming and HTTP Live Streaming" explaining how to resume downloads.

Found the following in a paragraph titled: "Resume Download"

AVAssetDownloadTask provides the ability to resume previously stopped downloads under certain circumstances. To do so, simply instantiate a new AVAssetDownloadTask with an AVURLAsset instantiated with a file NSURL pointing to the partially downloaded bundle with the desired download options, and the download will continue restoring any previously downloaded data.

So you would need to cancel the download, then save the local NSURL of the partial download passed to the didFinishDownloadingTo delegate. The cancelled download can the be resumed by passing it the local NSURL of the partially downloaded file.

like image 55
Craig Avatar answered Oct 21 '22 15:10

Craig