I am selecting a video from the photo library using UIImagePickerController. I have gotten the creation time and date of the video and I would like to get the location it was taken at. I know that the videos taken on the iphone have the location as part of their metadata but I don't know how to access it.
Here is the code I used for the dat and time.
else if (picker.sourceType ==UIImagePickerControllerSourceTypePhotoLibrary) {
NSURL * movieURL = [info valueForKey:UIImagePickerControllerMediaURL] ;
AVURLAsset *anAsset = [[AVURLAsset alloc] initWithURL:movieURL options:nil];
PHAsset *theAsset = [info valueForKey:UIImagePickerControllerMediaURL] ;
PHAsset *someAsset = [info valueForKey:UIImagePickerControllerPHAsset];
NSLog(@"someAsset%@",someAsset.location);
self.currentLocation = someAsset.location;
NSLog(@"creationDate1:%@",theAsset);
NSLog(@"creationDate2:%@",anAsset.creationDate.value);
NSDate *creationDate =(NSDate *)anAsset.creationDate.value;
NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MMMM-dd-yyyy"];
dayString = [dateFormatter stringFromDate:creationDate];
NSDateFormatter *dateFormatter2=[[NSDateFormatter alloc] init];
[dateFormatter2 setDateFormat:@"hh:mm a"];
timeString = [dateFormatter2 stringFromDate:creationDate];
I have tried to find the location key but with no luck.
Can someone show me how to do this or point me to a good tutorial and how to accomplish this. I am using objective-c.
Thanks for any and all help.
So I finally figured this out. I added these lines of code
PHAsset *someAsset = [info valueForKey:UIImagePickerControllerPHAsset];
NSLog(@"someAsset%@",someAsset.location);
self.currentLocation = someAsset.location;
I will change my original post to reflect changes.