目录中的视频缩略图图像 [英] Video thumbnail image from directory

查看:106
本文介绍了目录中的视频缩略图图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iOS中的新手。我想在图片视图中显示视频缩略图,这样点击按钮就可以打开一个图库,通过选择一个视频,它应该显示视频缩略图......请帮忙我...

I am a newbie in iOS.I want to show a video thumbnail in image view such that by clicking a Button it should open a gallery and by selecting a video it should display the video thumbnail...... please help me...

推荐答案

照片库中存储了视频和图像,首先你要从图书馆获取所有视频,在iOS 8之前,这篇文章向您展示了如何使用AssetsLibrary库获取图片。您可以在执行此操作时过滤视频,然后获得可以表示图像或视频的ALAsset,假设在您选择视频时,您获得ALAsset命名资源,使用以下功能将获得该视频的缩略图图像。

There are videos and images that stored on photo library, firstly you want to get all videos from the library, prior to iOS 8, this post shows you how to fetch pictures using AssetsLibrary library. You can filter videos out when doing it, then you get an ALAsset, which can represent a image or video, suppose when you select a video, you get a ALAsset named asset, using the below function will get you a thumbnail image for that video.

如果您使用ALAsset。

If you use ALAsset.

UIImage *thumbnail = [UIImage imageWithCGImage:[asset thumbnail]];

对于iOS 8,apple推出了一个新的照片库,您可以从库中获取所有视频,一个或多个视频由PHAsset表示,假设您有一个名为PHAsset的ivar资产,您可以使用以下方法从该资产中获取UIImage。看看 requestImageForAsset:targetSize:contentMode:options:resultHandler:,你可以将目标大小设置为你想要的拇指图像的大小,在resultHandler中,你得到UIImage。

For iOS 8, apple introduces a new Photos library,you can fetch all videos from the library as above, a video or images is represented by PHAsset, suppose you have a PHAsset ivar named asset, you can use the following method to get a UIImage from this asset. Take a look at requestImageForAsset:targetSize:contentMode:options:resultHandler:, you can set the target size to the size of the thumb image you want,in the resultHandler,you get the UIImage.

这篇关于目录中的视频缩略图图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆