Advertise here

Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

UIImagePickerController thumbnail of video which is pick up from library

GargamelGargamel Posts: 1New Users
edited April 2011 in iOS SDK Development

I am trying to get the thumbnail of the video which is pick up from library using the UIImagePickerController.

Here is my code. I can get the the thumbnail of video if I using the camera to record a video. But I can not get the thumbnail if I pick up a video from the library. Anybody know why?

-(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];

Sign In or Register to comment.