在UIImagePickerControllerDelegate的函数- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 中实现:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker dismissModalViewControllerAnimated:YES];
NSString *mediaType = [infoobjectForKey:UIImagePickerControllerMediaType];
if([mediaType isEqualToString:@"public.movie"])
{
NSURL *videoURL = [infoobjectForKey:UIImagePickerControllerMediaURL];
NSLog(@"found a video");
//获取视频的thumbnail
MPMoviePlayerController *player = [[[MPMoviePlayerControlleralloc]initWithContentURL:videoURL] autorelease];
UIImage *thumbnail = [playerthumbnailImageAtTime:1.0timeOption:MPMovieTimeOptionNearestKeyFrame];
player = nil;
}
}