Skip to main content

Create Animated Video thumbnail in android



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:-



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.

 compile 'com.github.bumptech.glide:glide:3.7.0'


Step:2 Load Video Thumbnail using Glide


For loading, the Thumbnail just use the glide method as given below.

Glide.with(context)
.load(urlofVideo)
.centerCrop()
.placeholder(anybackgroundColor)
.crossFade()
.into(ImagViewtoload);


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.

private void setScaleAnimation(View view) {
ScaleAnimation anim = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
anim.setDuration(FADE_DURATION);
view.startAnimation(anim);
}


Don't Forget to define the FADE_DURATION variable in your class it can be defined as:

   private final static int FADE_DURATION = 1000;


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.

setScaleAnimation(((VideoViewHolder) holder).vImage);


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.
setScaleAnimation(imageView);

Animated Video Thumbnail

Download our Video Gallery Demo App for working demo and if you want checks out the complete working tutorial then check out How to create Video Gallery in Android Tutorial.

Comments

  1. Such beautifully written. And the information provided is very useful. Thanks for sharing such informative and interesting article.Check this out too ecommerce website development dubai.Thanks!

    ReplyDelete

Post a Comment

Popular posts from this blog

Flutter How to Start Android Activity from Flutter View

Flutter and Dart is an excellent combination for creating the UI, but for accessing the platform-specific service we need to open platform-specific activity. So lets in this article we will explore how to start an android activity and access the service from Flutter View. Create a Project for this Android Activity Flutter View Demo Create a Project From File menu select the New Flutter Project Enter the project name Select the AndroidX support and click on next After the above, we step click on Finish We will have the following project structure created. Create the Second Activity in Android Just go to the android folder and open it in separate windows. We will have the following project structure. Create the Activity Just right-click on the Kotlin folder and create a blank activity from the menu. If you create the activity then you may be required to upgrade the Gradle and do some import. So Just click on update and wait for the project s

Kotlin Parcelable Array Objects Send To Activity

We know that IPC (Inter Process Communication) between the activity is an extremely important part of any application development. We often required that we need to send some data to other activity. For example, we may be required to send an array of data, data could be an Integer, String, Long, Double, Float or any other custom data objects. So, In this example, we are going to learn how to implement the Kotlin Parcelable Array object to send the data from one activity to second activity. What is Parcel? The parcel class is designed as a high-performance IPC transport. A Parcel can contain both flattened data that will be unflattened on the other side of the IPC, and references to live IBinde r objects that will result in the other side receiving a proxy IBinder connected with the original IBinder in the Parcel. Create Kotlin Parcelable Array Objects Parcelable is API for placing the arbitrary objects into the Parcel. In Actual in android app development, Parcelable is an interface

Scan and List All Available WiFi Network In Android

In this tutorial, we learn how to connect to a WiFi hotspot in android by code. In this Demo we will create an as small app which will scan the all available network or Hotspot and list down the network when you select specific network, the application will connect that particular network. You May Like Below Topic: How to Read and Write JSON data using GSON WP Android App using REST and volley WP Android App using REST and volley part2 Implementation of SwipeRefreshLayout in RecyclerView Create Amazing Bottom Navigation Bar Without Any External Library Introduction In this tutorial, we learn how to connect to a WiFi hotspot in android by code. In this Demo we will create an as small app which will scan the all available network or Hotspot and list down the network when you select specific network, the application will connect that particular network. We will add this functionality to our existing Demo app " Video Gallery ". If you would like to check out t