Advertisement
Guest User

Untitled

a guest
Apr 21st, 2014
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. int timestamp = [[NSDate date] timeIntervalSince1970];
  2. NSURL *videoURL = _movieURL;
  3. NSData *videoData = [NSData dataWithContentsOfFile: videoURL];
  4.  
  5. NSString *videoString = [NSString stringWithFormat:@"%d.MOV", timestamp];
  6. NSString *videoPath = [documentsPath stringByAppendingPathComponent: videoString]; //Add the file name
  7.  
  8. [videoData writeToFile:videoPath atomically:NO];
  9.  
  10.  
  11. -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
  12. self.movieURL = info[UIImagePickerControllerMediaURL];
  13. // NSLOg("MOVIE URL: %@", _movieURL);
  14. [picker dismissViewControllerAnimated:YES completion:NULL];
  15. }
  16.  
  17. NSURL *videoURL = _movieURL;
  18.  
  19. NSData *videoData = [NSData dataWithContentsOfFile: videoURL];
  20.  
  21. NSData *videoData = [NSData dataWithContentsOfURL: videoURL];
  22.  
  23. UISaveVideoAtPathToSavedPhotosAlbum (
  24. moviePath, nil, nil, nil);
  25.  
  26. - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info; {
  27. // Handle a movie capture
  28. if (CFStringCompare ((CFStringRef) mediaType, kUTTypeMovie, 0)
  29. == kCFCompareEqualTo) {
  30.  
  31. NSString *moviePath = [[info objectForKey:
  32. UIImagePickerControllerMediaURL] path];
  33.  
  34. if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (moviePath)) {
  35. UISaveVideoAtPathToSavedPhotosAlbum (
  36. moviePath, nil, nil, nil);
  37. }
  38. }
  39. }
  40.  
  41. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  42. NSString *documentsDirectory = [paths objectAtIndex:0];
  43. NSDate *aDate = [NSDate date];
  44. NSTimeInterval interval = [aDate timeIntervalSince1970];
  45. NSString *localFilePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%d.mov",(int)interval]];
  46. [vidData writeToFile:localFilePath atomically:YES];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement