iphone 3.1.2 sdk用于类型电影的UIImagePicker不复制缩略图

时间:2009-11-04 01:32:45

标签: iphone iphone-sdk-3.0 ffmpeg uiimagepickercontroller

我已经看到这个问题弹出了几次,但作者认为对错误答案感到满意,所以我会再问一遍。

当从用户的图库中挑选一部电影时,我在tmp目录中获得了MOV,但我现在没有在3.1+ sdk中获得该电影的缩略图。在sdk 3.0中,您在tmp文件夹中获得了一个jpg,但此行为已停止。

除了ffmpeg之外,还有答案可以获得拇指吗?什么东西支持sdk?

他们直接拍摄视频时会得到一个拇指。

这个答案错了​​:iphone sdk > 3.0 . Video Thumbnail?

1 个答案:

答案 0 :(得分:2)

找到答案,但我不得不等到iOS4(该功能在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];
    }
}