Android: Is it possible to display video thumbnails?
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);
How do I get thumbnail of a video in android
You can use glide.
its automatically set thumb image of video.
Glide is also able to display the thumbnail of videos, as long as they're stored on the phone. Let's assume you get the file path by letting the user select a video: Based on this document https://futurestud.io/tutorials/glide-displaying-gifs-and-videos
String filePath = "/storage/emulated/0/Pictures/example_video.mp4";
Glide
.with(context)
.asBitmap()
.load(Uri.fromFile(new File(filePath)))
.into(imageViewGifAsBitmap);
how can I show a video thumbnail from a video path?
It is the default way to create a thumbnail.
For Mini Kind
Bitmap thumb;
//MINI_KIND, size: 512 x 384 thumbnail
thumb = ThumbnailUtils.createVideoThumbnail(filePath, MediaStore.Video.Thumbnails.MINI_KIND);
img_tumbnail.setImageBitmap(thumb);
For Micro Kind
Bitmap thumb;
//MICRO_KIND, size: 96 x 96 thumbnail
thumb= ThumbnailUtils.createVideoThumbnail(filePath, Thumbnails.MICRO_KIND);
img_tumbnail.setImageBitmap(thumb);
Also, you can use Glide for Url as well as Video path of Device.
Glide.with(context).with(this)
.asBitmap()
.load(videoFilePath) // or URI/path
.into(imgView); //imageview to set thumbnail to
also, you can resize thumbnail by using .override(50,50)
with Glide.
Related Topics
Is Asynctask Really Conceptually Flawed or Am I Just Missing Something
Adb Android Device Unauthorized
How to Check If My Edittext Fields Are Empty
Determine If Android App Is Being Used For the First Time
How to Set Ringtone in Android from My Activity
Push Notification Works Incorrectly When App Is on Background or Not Running
How to Use Asynctask Correctly in Android
Why Does Layoutinflater Ignore the Layout_Width and Layout_Height Layout Parameters I'Ve Specified
How to Make the Corners of a Button Round
How to Add Calendar Events in Android
Firestore: Permission_Denied: Missing or Insufficient Permissions
Setbackground VS Setbackgrounddrawable (Android)
How to Change Datepicker Dialog Color for Android 5.0
How to Dismiss the Dialog with Click on Outside of the Dialog