我在画廊中有一个视频。点击它试图打开,但而不是我想在uiimageview中显示视频的缩略图。
答案 0 :(得分:0)
AVURLAsset *asset;
if ([url isFileURL]) {
asset = [[AVURLAsset alloc] initWithURL:url options:nil];
}
AVAssetImageGenerator *gen = [[AVAssetImageGenerator alloc] initWithAsset:asset];
gen.appliesPreferredTrackTransform = YES;
CMTime time = CMTimeMakeWithSeconds(0.0, 600);
NSError *error = nil;
CMTime actualTime;
CGImageRef image = [gen copyCGImageAtTime:time actualTime:&actualTime error:&error];
UIImage *thumb = [[UIImage alloc] initWithCGImage:image];
UIImage *finalThumpnailImage = [HPLUtility createThumpnailImageFromTheImage:thumb]; //Resized image.
CGImageRelease(image);
return finalThumpnailImage;