How to load thumbnail of video from Storage (File Uri) with and without Glide

In our application when we want to show list of video as thumbnail below code might be useful. It uses MediaStore.Video.Thumbnails for thumbnail. It provide two types of thumbnails first is MICRO_KIND and second is MINI_KIND. As from the name MICRO_KIND provides bigger thumbnail as compares to MICRO_KIND.

To load thumbnail of video from storage we need access permission of storage. So it’s most important point to first declare READ_EXTERNAL_STORAGE in AndroidManifest. 

It is also important that we have ask permission at Run time for devices with API >= 23.

So start with permission in AndroidManifest. Here is the code for the AndroidManifest.

Now for the next step. We load thumbnail in two ways, i.e. one with using Glide and second without Glide. In our activity_main xml file add two Buttons.

 

In below Kotlin code we have implemented onClickListener  for two Buttons. In onClick first check for the read access permission, if not granted then ask permissions at run time. I have added video directly to storage and used path for the video. Alternatively, you can implement separate logic to get video files from storage.

Finally we can get result like below shown in screens, With and without using Glide.

Leave a Comment

Your email address will not be published. Required fields are marked *