0

I can get the .MOV file with the Image Picker, but how can I find the location it was taken at and the time it was taken?

My image picker: - (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info {

NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
[self dismissViewControllerAnimated:NO completion:nil];

// Handle a movie capture
if (CFStringCompare ((__bridge_retained CFStringRef)mediaType, kUTTypeMovie, 0)
    == kCFCompareEqualTo) {

    NSString *movieFile = [[info objectForKey:
                            UIImagePickerControllerMediaURL] path];
    NSURL *movieURL = [NSURL fileURLWithPath:movieFile];

    NSLog(@"Movie File %@",movieURL);

    [self dismissViewControllerAnimated:YES completion:nil];
}
}
user2480176
  • 147
  • 3
  • 13

1 Answers1

1

I don't know about the location it was taken but you can use File Attribute Keys to get the NSFileCreationDate using attributesOfItemAtPath:error:. There is a convenience method on NSDictionary fileCreationDate

NSError *error;
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:movieFile error:&error];
if (!attributes) {
    // Use the error
}
NSDate *createdDate = [attributes fileCreationDate];

If you want to access the meta-data on the MOV file you can have a look at the EXIF data, I don't know if there is a iOS library for this though.

Community
  • 1
  • 1
Rich
  • 8,108
  • 5
  • 46
  • 59
  • Thank you very much. You should edit the last line to be `NSDate *createdDate = [attributes objectForKey:NSFileCreationDate];` instead. It returned the whole date instead of just part. – user2480176 Mar 12 '14 at 02:36
  • As per the docs [`fileCreationDate`](https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/Reference/Reference.html#//apple_ref/occ/instm/NSDictionary/fileCreationDate) is the same as `[attributes objectForKey:NSFileCreationDate]`, are you saying this is not the case?! – Rich Mar 12 '14 at 08:18
  • Nope I miss read my console. You are completely right. My apologies. – user2480176 Mar 12 '14 at 18:25
  • Ah no problem! Just wanted to check. Hope this is what you're looking for too :) – Rich Mar 12 '14 at 19:01