我想从iCloud下载PHAsset视频到应用程序的临时目录。怎么做,如果可能的话?
答案 0 :(得分:3)
此代码可以帮助您入门:
PHImageManager* manager = [PHImageManager defaultManager];
PHVideoRequestOptions* requestOptions = [PHVideoRequestOptions new];
requestOptions.networkAccessAllowed = YES;
requestOptions.progressHandler = ^(double progress, NSError* error, BOOL* stop, NSDictionary* info) {
NSLog(@"cacheAsset: %f", progress);
};
[manager requestExportSessionForVideo:inAsset
options:requestOptions
exportPreset:AVAssetExportPresetPassthrough resultHandler:^(AVAssetExportSession* exportSession, NSDictionary* info) {
exportSession.outputURL = url;
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
// Do something here with the result. Make sure to check the info dictionary for additional status.
}];
}];