Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Is it possible to display video thumbnails?

Tags:

android

I created a video recording application with library dialog. The library dialog displays the list of recorded videos where each item consists of icon, video title, tags and location information the following way:

alt text

Does anyone know whether it is possible to replace icons with video thumbnails (single frame preview)?

Thanks!

like image 765
Niko Gamulin Avatar asked Aug 26 '09 13:08

Niko Gamulin


People also ask

Can we make video as a thumbnail?

Add automatic or custom thumbnails Open the YouTube app . Your videos. Edit thumbnail . Select an auto-generated thumbnail or tap Custom thumbnail to create a custom video thumbnail from an image on your device.

How do I get the thumbnail from a video URI?

This works for me: Bitmap thumb = ThumbnailUtils. createVideoThumbnail(filePath, Thumbnails. MINI_KIND);


2 Answers

if you don't or cannot go through cursor and if you have only paths or File objects, you can use since API level 8 (2.2) public static Bitmap createVideoThumbnail (String filePath, int kind)

Android documentation

The following code runs perfectly:

Bitmap bMap = ThumbnailUtils.createVideoThumbnail(file.getAbsolutePath(), MediaStore.Video.Thumbnails.MICRO_KIND); 
like image 141
Damien Praca Avatar answered Nov 07 '22 04:11

Damien Praca


If you are using API 2.0 or newer this will work.

int id = **"The Video's ID"** ImageView iv = (ImageView ) convertView.findViewById(R.id.imagePreview); ContentResolver crThumb = getContentResolver(); BitmapFactory.Options options=new BitmapFactory.Options(); options.inSampleSize = 1; Bitmap curThumb = MediaStore.Video.Thumbnails.getThumbnail(crThumb, id, MediaStore.Video.Thumbnails.MICRO_KIND, options); iv.setImageBitmap(curThumb); 
like image 36
Greg Zimmers Avatar answered Nov 07 '22 06:11

Greg Zimmers