I have an application where I record video. But when the recording is finished, I can not save the video right away. First I need to show the agreement. So I am trying to save the URL that I get from the image picker. And save the video to the library later. This worked fine in iOS4, but not in iOS5. I am new to iOS and Objective-C, so I probably made a completely incorrect property declaration, which should contain a URL.
This is the code:
.h
#import <UIKit/UIKit.h>
#import <AssetsLibrary/AssetsLibrary.h>
@interface Video_recViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIActionSheetDelegate> {
NSURL *tempMoviePath;
}
@property (nonatomic, retain) NSURL *tempMoviePath;
.m
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSURL *moviePath = [info objectForKey:UIImagePickerControllerMediaURL];
[self dismissModalViewControllerAnimated: YES];
NSLog(@"path from image picker: %@", moviePath);
tempMoviePath = moviePath;
NSLog(@"temp movie path: %@", tempMoviePath);
[self performSelector:@selector(showAgree) withObject:nil afterDelay:0.5];
}
- (void)userAgreed {
NSLog(@"user agreed");
[self saveMyVideo:tempMoviePath];
}
- (void)saveMyVideo:(NSURL *)videoURL {
NSLog(@"saving movie at: %@", videoURL);
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:videoURL])
{
[library writeVideoAtPathToSavedPhotosAlbum:videoURL
completionBlock:^(NSURL *assetURL, NSError *error){}
];
}
[library release];
}
Log out when didFinishPickingMediaWithInfo:
temp movie path: file://localhost/private/var/mobile/Applications/8CFD1CB7-70A0-465C-B730-817ACE5A4F78/tmp/capture-T0x119660.tmp.hNFzkY/capturedvideo.MOV
Log out when executing "saveMyVideo". The URL suddenly turned into this !!
saving movie at: (
"0.31269",
"0.32899",
"0.63999",
"0.33001",
"0.3",
"0.6",
"0.15",
"0.05999"
)
source
share