将iCloud视频下载到临时目录

时间:2015-10-29 10:35:30

标签: ios download icloud phasset

我想从iCloud下载PHAsset视频到应用程序的临时目录。怎么做,如果可能的话?

1 个答案:

答案 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.
                                 }];
                             }];