当我使用 UISaveVideoAtPathToSavedPhotosAlbum 在相册中保存视频时,如何在 assets-library://asset/asset.mov ....中检索它的新资产URL? / strong>格式
//outputURL.path is : file:///private/var/mobile/Applications/4535724C-7ABD-4F00-A363-9A62022F8EB0/tmp/trim.E8CD7632-7C52-4EA4-A462-8C5131B214AA.MOV.exp.mov
UISaveVideoAtPathToSavedPhotosAlbum(outputURL.path, self, @selector(video:didFinishSavingWithError:contextInfo:), nil);
答案 0 :(得分:4)
而不是UISaveVideoAtPathToSavedPhotosAlbum
,您可以使用-[ALAssetsLibrary writeVideoAtPathToSavedPhotosAlbum:(NSURL *)videoPathURL completionBlock (ALAssetsLibraryWriteVideoCompletionBlock)completionBlock]
方法(Apple Documentation here)
例如:
ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
[library writeVideoAtPathToSavedPhotosAlbum:videoPathURL
completionBlock:^(NSURL *assetURL, NSError *error)
{
/* process assetURL */
}];
重要提示:处理ALAssetsLibrary时要记住的重要事项是assetURL仅对ALAssetsLibrary实例的生命周期有效。因此,确保在完成assetURL和任何关联的ALAsset处理之后,保留对库的引用。