Save UIImagePicker Video

I searched and searched, but I can’t find the basic video saving code UIImagepicker. Everything is set up for me and I have empty space.

- (void)imagePickerController:(UIImagePickerController *)
         picker didFinishPickingMediaWithInfo:(NSDictionary *)
              info{
}

I know this has something to do with the dictionary, but after that I lost any help?

+3
source share
1 answer

Try this code to save the video in a photo album.

    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    {
        [self dismissModalViewControllerAnimated:YES];

        //get the videoURL 
        NSString *tempFilePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];

        if ( UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(tempFilePath))
        {
                // Copy it to the camera roll.
                UISaveVideoAtPathToSavedPhotosAlbum(tempFilePath, self, @selector(video:didFinishSavingWithError:contextInfo:), tempFilePath);
            } 
    }

    - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
        [self dismissModalViewControllerAnimated:YES];
    }

    - (void) video: (NSString *) videoPath
    didFinishSavingWithError: (NSError *) error
       contextInfo: (void *) contextInfo {
        NSLog(@"Finished saving video with error: %@", error);
    }
+8
source

All Articles