Rabu, 13 Maret 2019

is it possible to "Pause" and "Resume" AVAssetDownloadTask?

so far i found only two options for downloading video either "Resume" or "cancel"/"Suspend". is there any possible way to pause downloading video in middle and resume the download from where it stopped. I am using below code to download and store the video.


// Create new background session configuration.
NSURLSessionConfiguration *urlSessionConfiguration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:@"assetDowloadConfigIdentifier"];
AVAssetDownloadURLSession *avAssetDownloadSession = [AVAssetDownloadURLSession sessionWithConfiguration:urlSessionConfiguration assetDownloadDelegate:self delegateQueue:[NSOperationQueue mainQueue]];

NSURL *assetURL = [NSURL URLWithString:@"https://a4i6y2k6.stackpathcdn.com/vistvorigin/smil:4b0d690b7b3bc8ac5da2049f50c80794c762423e.smil/playlist.m3u8"];

AVURLAsset *hlsAsset = [AVURLAsset assetWithURL:assetURL];

if (@available(iOS 10.0, *)) {

AVAssetDownloadTask *avAssetDownloadTask = [avAssetDownloadSession assetDownloadTaskWithURLAsset:hlsAsset assetTitle:@"downloadedMedia" assetArtworkData:nil options:nil];

if([command isEqualToString:@"resume"]){
// Start task and begin download
[avAssetDownloadTask resume];
}else{
[avAssetDownloadTask cancel];
}

} else {
// Fallback on earlier versions
}



from is it possible to "Pause" and "Resume" AVAssetDownloadTask?

is it possible to "Pause" and "Resume" AVAssetDownloadTask? Rating: 4.5 Diposkan Oleh: Admin

0 komentar:

Posting Komentar

Popular Posts