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:
Does anyone know whether it is possible to replace icons with video thumbnails (single frame preview)?
Thanks!
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.
This works for me: Bitmap thumb = ThumbnailUtils. createVideoThumbnail(filePath, Thumbnails. MINI_KIND);
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);
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With