我想在我的uiimageview for iphone中显示来自网址的视频的视频图像 [英] I want to display a videothumbnail image of a video from url in my uiimageview for iphone
本文介绍了我想在我的uiimageview for iphone中显示来自网址的视频的视频图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以获取视频的第一个图像帧并在uiimageview中显示它。我的视频保存在服务器中。我需要调用网址来播放视频
Is it possible to get the first image frame of a video and display it in uiimageview . My video is saved in the server. i need to call the url to play the video
推荐答案
我用这种方法做同样的事情
I use this method to do the same
/**
* This method retunrs a thumbnail of a Video file
*/
+ (UIImage *)generateThumbnailIconForVideoFileWith:(NSURL *)contentURL WithSize:(CGSize)size
{
UIImage *theImage = nil;
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:contentURL options:nil];
AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
generator.maximumSize=size;
generator.appliesPreferredTrackTransform = YES;
NSError *err = NULL;
CMTime time = CMTimeMake(100,100); //change whatever you want here.
CGImageRef imgRef = [generator copyCGImageAtTime:time actualTime:NULL error:&err];
theImage = [[UIImage alloc] initWithCGImage:imgRef] ;
CGImageRelease(imgRef);
return theImage;
}
这篇关于我想在我的uiimageview for iphone中显示来自网址的视频的视频图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文