I have an app in which the viewer can either open the camera to take a video or they can choose a video from the photoLibrary. I use two different actions and buttons to do this using UIImagePickerController.
I then save each one to the documents directory with a new name and I also save the video from the camera to the photoLibrary.
I don't code saving the video chosen from the photoLibrary back to the photo album but somehow it is. If I remove the code that saves the captured video to the photo album then the chosen video is not saved back to the photo album.
How do I capture a video using the camera and save it to the photo album but NOT save a video chosen from the photoLibrary back to the photo album. Any Ideas would be greatly appreciated.
Code:
//get it from the camera
-(IBAction) captureMovie:(id)sender;
{ UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
NSArray *mediaTypesAllowed = [NSArray arrayWithObject:@"public.movie"];
picker.mediaTypes = mediaTypesAllowed;
picker.delegate = self;
[self presentModalViewController: picker animated:YES];
}
//get it from the photoLibrary
-(IBAction) findMovie:(id)sender;
{ UIImagePickerController *picker2 = [[UIImagePickerController alloc] init];
picker2.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
NSArray *mediaTypesAllowed2 = [NSArray arrayWithObject:@"public.movie"];
picker2.mediaTypes = mediaTypesAllowed2;
picker2.delegate = self;
[self presentModalViewController: picker2 animated:YES];
}
I then save each one to the documents directory with a new name and I also save the video from the camera to the photoLibrary.
Code:
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{ NSURL * movieURL = [info valueForKey:UIImagePickerControllerMediaURL] ;// Get the URL of where the movie is stored.
NSData * movieData = [NSData dataWithContentsOfURL:movieURL];
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
//here I save the camera video to the documents directory
[ movieData writeToFile:fullPath atomically:YES];
//and here I save it to the photo album
UISaveVideoAtPathToSavedPhotosAlbum(fullPath, nil, nil, nil) ;
- (void) imagePickerController1:(UIImagePickerController *)picker2 didFinishPickingMediaWithInfo:(NSDictionary *)info2
{ NSURL * movieURL2 = [info2 valueForKey:UIImagePickerControllerMediaURL] ;
NSData * movieData2 = [NSData dataWithContentsOfURL:movieURL2];
NSArray *documentPaths2 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
//here I save the photoLibrary video to the documents directory
[ movieData2 writeToFile:fullPath2 atomically:YES];
//I do not save it to the photo album
I don't code saving the video chosen from the photoLibrary back to the photo album but somehow it is. If I remove the code that saves the captured video to the photo album then the chosen video is not saved back to the photo album.
How do I capture a video using the camera and save it to the photo album but NOT save a video chosen from the photoLibrary back to the photo album. Any Ideas would be greatly appreciated.