我正在使用ASIHttpRequest下载视频文件,我可以在下载完成后在目标路径中获取下载的文件。但根据我的要求,我想使用MPMoviePlayerController
播放当前下载的视频,如何以NSData
格式获取当前下载的字节以与MPMoviePlayerController
一起播放?
即。如果视频是200mb,我已经下载了50mb,那么在下载剩余视频时我也可以播放50mb视频。
这是我下载文件的代码。
NSURL *url = [NSURL URLWithString:urlString];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request setTag:tag];
[request setTimeOutSeconds:60.f];
[request setShowAccurateProgress:YES];
[request setDownloadProgressDelegate:progressView];
[request setDidFinishSelector:@selector(requestFinished:)];
[request setDidFailSelector:@selector(requestFailed:)];
// These delgates won't working
// [request setDidReceiveResponseHeadersSelector:<#(SEL)#>]
// [request setDidStartSelector:<#(SEL)#>]
[request setDownloadDestinationPath:downloadPath];
[request setAllowResumeForFileDownloads:YES];
[request setShouldContinueWhenAppEntersBackground:YES];
[request startAsynchronous];
//this will not call because I set UIProgressView to show downloading progress, to call it I need to set `self`
-(void)request:(ASIHTTPRequest *)request didReceiveBytes:(long long)bytes
运气好吗?其他解决方案?