获取URL保存到照片专辑的视频的信息



我保存了使用AVAsset使用CC_2使用writeVideoAtPathToSavedPhotosAlbum的视频,如下所示。

    NSString* filename = [NSString stringWithFormat:@"capture%d.mp4", _currentFile];
    NSString* path = [NSTemporaryDirectory() stringByAppendingPathComponent:filename];
    NSURL* url = [NSURL fileURLWithPath:path];
    dispatch_async(dispatch_get_main_queue(), ^{
        [_encoder finishWithCompletionHandler:^{
            ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
            [library writeVideoAtPathToSavedPhotosAlbum:url completionBlock:^(NSURL *assetURL, NSError *error){
                NSLog(@"save completed");
            }];
        }];
    });

但是,保存视频后,我想像使用UIImagePickerController时所获得的"保存的视频信息"。

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [picker dismissViewControllerAnimated:YES completion:NULL];
    NSLog(@"there");
    // Handle a movie capture
    NSString *type = info[UIImagePickerControllerMediaType];
    NSURL *videoURL = info[UIImagePickerControllerMediaURL];
    //do things with that info
}

这是保存视频并在自定义相册中添加该视频的代码,然后告知保存位置。

 [library writeVideoAtPathToSavedPhotosAlbum:videoInputUrl completionBlock:^(NSURL *assetURL, NSError *error){
    if (error) {
        NSLog(@"Video could not be saved");
    }
    else{
            [library assetForURL:assetURL
                     resultBlock:^(ALAsset *asset) {
                         // assign the photo to the album
                         [groupToAddTo addAsset:asset];
                         NSLog(@"Added Successfully %@ to %@", [[asset defaultRepresentation] filename], albumName);
                         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Success" message:@"Video Saved to xyz Album."  delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil, nil];
                         [alert show];
                     }
                    failureBlock:^(NSError* error) {
                        NSLog(@"failed to retrieve image asset:nError: %@ ", [error localizedDescription]);
                    }];
    }
}];

希望这对您有帮助...:)

最新更新