Save In-App Video To Camera Roll?
camera, iphone, video
Solution
You could try this code assuming you already know how to save an image:
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if([mediaType isEqualToString:(NSString *)kUTTypeMovie]) {
//Save the video
NSURL *movieUrl = [info objectForKey:UIImagePickerControllerMediaURL];
UISaveVideoAtPathToSavedPhotosAlbum([movieUrl relativePath], self,@selector(movie:didFinishSavingWithError:contextInfo:), nil);
}
}
Or you could try:
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
if([mediaType isEqualToString:(NSString *)kUTTypeMovie]) {
NSURL *movieUrl = [info objectForKey:UIImagePickerControllerMediaURL];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeVideoAtPathToSavedPhotosAlbum:movieUrl completionBlock:^(NSURL *assetURL, NSError *error){
if(error) {
NSLog(@"CameraViewController: Error on saving movie : %@ {imagePickerController}", error);
}
else {
NSLog(@"URL: %@", assetURL);
}
}];
}
}
Problem
Is it possible to take a video that is embedded within the app and save it to the camera roll? If so, how? Is it the same UIWriteImage thing?