我想要使用UIImagePickerController從視頻庫中選取視頻的縮略圖。UIImagePickerController從視頻庫中選取的視頻縮略圖
這是我的代碼。如果我使用相機錄製視頻,我可以獲得視頻的縮略圖。但是如果我從圖書館拿起視頻,我無法得到縮略圖。任何人都知道爲什麼?
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:(NSString *)kUTTypeMovie])
{
NSURL *mediaUrl = [info objectForKey:UIImagePickerControllerMediaURL];
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:mediaUrl];
moviePlayer.shouldAutoplay = NO;
UIImage *thumbnail = [[moviePlayer thumbnailImageAtTime:0.0 timeOption:MPMovieTimeOptionNearestKeyFrame] retain];
[imageView setImage:thumbnail]; //imageView is a UIImageView
[moviePlayer release];
[thumbnail release];
[self dismissModalViewControllerAnimated:YES];
}
}
任何人都可以幫助我嗎? – Gargamal 2011-05-06 16:31:08