0
我有UIImageView从哪里我把图像从网址(数据库)。但有一个问题:一些网址不是图像,而是指向YouTube或其他网站的链接。有没有可能将视频添加到UIImageView?我怎样才能做到这一点?UIImageView图像或视频
帮助!谢谢。
我有UIImageView从哪里我把图像从网址(数据库)。但有一个问题:一些网址不是图像,而是指向YouTube或其他网站的链接。有没有可能将视频添加到UIImageView?我怎样才能做到这一点?UIImageView图像或视频
帮助!谢谢。
UIImageView只能显示图像。但你可以从视频创建缩略图并在imageview中显示。你可以在数据库端设置标志,如果url是图像,则设置标志= 1,如果url是视频,则标志= 2。或者您可以确定使用扩展名。从url分割扩展。
,并可以生成从视频像拇指图像..
NSURL *videoURl = [NSURL fileURLWithPath:videoPath];
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:videoURl options:nil];
AVAssetImageGenerator *generate = [[AVAssetImageGenerator alloc] initWithAsset:asset];
generate.appliesPreferredTrackTransform = YES;
NSError *err = NULL;
CMTime time = CMTimeMake(1, 60);
CGImageRef imgRef = [generate copyCGImageAtTime:time actualTime:NULL error:&err];
UIImage *img = [[UIImage alloc] initWithCGImage:imgRef];
[YourImageView setImage:img];
[img release];
的UIImageView只能显示图像。如果您可以确定从数据库中获得的URL是否为管道,则可以从视频创建缩略图并在UIImageView中显示它。 – 8Ours 2013-04-28 07:38:20
也许一些例子代码? TNX – user1832330 2013-04-28 09:08:52