如何在Android中检索视频缩略图



我的SD卡视频文件夹包含许多.mp4视频文件。根据我的要求,我想在我的android应用程序列表视图中列出这些视频文件,并附上它们的"缩略图"《名称》。顺便说一句,我计划使用Picasso通用图像加载程序进行图像缓存。请告诉我有谁知道怎么做?

import android.provider.MediaStore.Video.Thumbnails;

您可以从视频中获得两种预览缩略图大小:

用于96 x 96 的缩略图.MICRO_KIND

缩略图.MINI_KIND用于512 x 384像素

使用此代码

String filePath = "/sdcard/DCIM/Camera/my_video.mp4"; //change the location of your file!
ImageView imageview_mini = (ImageView)findViewById(R.id.thumbnail_mini);
ImageView imageview_micro = (ImageView)findViewById(R.id.thumbnail_micro);
Bitmap bmThumbnail;

bmThumbnail = ThumbnailUtils.createVideoThumbnail(filePath, Thumbnails.MINI_KIND);
imageview_mini.setImageBitmap(bmThumbnail);

检查此链接

最新更新