/**
将视频转为livephoto保存到本地
@param videoPath 视频地址
@param imagePath 图片地址
@param saveHandle 返回回调
*/
- (void)saveLivePhotoWithVideoPath:(NSString *)videoPath
imagePath:(NSString *)imagePath
handle:(void(^)(BOOL,NSError *))saveHandle;
- (void)saveLivePhotoWithVideoPath:(NSString *)videoPath imagePath:(NSString *)imagePath handle:(void(^)(BOOL,NSError *))saveHandle{
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetCreationRequest *creationRequest = [PHAssetCreationRequest creationRequestForAsset];
PHAssetResourceCreationOptions *options = [[PHAssetResourceCreationOptions alloc] init];
[creationRequest addResourceWithType:PHAssetResourceTypePairedVideo fileURL:[NSURL fileURLWithPath:videoPath] options:options];
[creationRequest addResourceWithType:PHAssetResourceTypePhoto fileURL:[NSURL fileURLWithPath:imagePath] options:options];
} completionHandler:^(BOOL success, NSError * _Nullable error) {
saveHandle(success,error);
}];
}
网友评论