I looked through, but could not find a solution to my problem. I am trying to save some video files in my application directory. I do it as follows:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *appFile = [documentsDirectory stringByAppendingPathComponent:@"myFile"];
NSLog(@"%@",appFile);
[[NSUserDefaults standardUserDefaults] setValue:appFile forKey:@"videoURL"];
[[NSUserDefaults standardUserDefaults]synchronize];
NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
NSData *webData = [NSData dataWithContentsOfURL:videoURL];
[webData writeToFile:appFile atomically:YES];
My question is, is this the right way to save a movie file, and if so, how can I convert NSData to a file that can be played through MPMoviePlayer? Thank you for your help.
PS. I really do not want to use the photo library, since the application is likely to contain a lot of videos.
source
share