1

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

4

1 回答 1

2

这段代码应该让你开始:

 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.
                                 }];
                             }];
于 2015-11-09T23:08:57.863 回答