iphone 3.1.2 sdk UIImagePicker for type movie not copying a thumbnail
I have seen this question pop up a few times but the authors see to be satisfied with the wrong answer, so I will ask again.
When picking a movie out of the user's gallery, I am given a MOV in the tmp directory but I am not given the thumbnail for the movie now in the 3.1+ sdk. In sdk 3.0, you get a jpg in the tmp folder but this behavior has stopped.
Is there an answer to get the thumb besides ffmpeg? Anything supported by the sdk?
I 开发者_StackOverflowget a thumb when they shoot a video directly.
This answer is wrong: iphone sdk > 3.0 . Video Thumbnail?
Found the answer, but I had to wait until iOS4 (the feature came out in 3.2)
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType compare:(NSString*)kUTTypeMovie] == NSOrderedSame) {
// deal with the movie
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
NSURL *mediaUrl = [info objectForKey:UIImagePickerControllerMediaURL];
NSLog(@"media Url = %@, path %@", mediaUrl, [mediaUrl path]);
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:mediaUrl];
UIImage *thumbnail = [[moviePlayer thumbnailImageAtTime:0.0 timeOption:MPMovieTimeOptionNearestKeyFrame] retain];
[moviePlayer release];
NSLog(@"thumbnail = %@", thumbnail);
[thumbnail release];
}
}
精彩评论