Table of Contents
In this tutorial, we learn how to create animated video thumbnail of any video. At the time of loading, the animation is very useful for making the good user experience.
Here, we will use glide for loading the Video Thumbnail into ImageView. Glide is very easy to use the library for loading any thumbnail or image.
Even you don’t have to create the thumbnail, download the image from any web URL and anything else. You have to just provide the URI of your video it doesn’t matter whether your Image or Video stored locally on your storage or some remote or web location over the internet.
You May Like:-
- Create Image and Video Thumbnail on Android
- How to create Video Gallery App Using RecyclerView
- How to Read and Write JSON data using GSON
- WP Android App Using REST and Volley
Step:1 How to add Glide library to your project
You can download the Glide library from Github. Alternatively, you can use the build.gradle files to automatically add glide library to your project under dependency.
Step:2 Load Video Thumbnail using Glide
For loading, the Thumbnail just use the glide method as given below.
Step:3 Create an Animation method in your Adapter
To create the animation method, first of all, you have decided the animation type. There are many types of animation that you can use in your project.
Here, in below code, we are using the scale animation, where thumbnail comes from out from image view and fill the complete ImageView.
Don’t Forget to define the FADE_DURATION variable in your class it can be defined as:
Step:4 Set the Animation to your ImageView
Further, for setting the animation to your ImageView you just need to use the below code. Where we are just calling the previously created method.
Here ((VideoViewHolder) holder).vImage is the simple image if you are not using any View holder want to use it with the simple image then you can use as given below.