Search code examples
androiduniversal-image-loaderpicasso

How to retrieve the video thumbnail in Android


My sdcard video folder contains number of .mp4 video files. According to my requirement I want to list down those video files in my android application listview with their "Thumbnail" and "Name". BTW I plan to use Picasso or Universal image loader for image caching. Please tell me anyone know how to do?


Solution

  • import android.provider.MediaStore.Video.Thumbnails;
    

    You can get two preview thumbnail sizes from the video:

    Thumbnails.MICRO_KIND for 96 x 96

    Thumbnails.MINI_KIND for 512 x 384 px

    use this code

    String filePath = "/sdcard/DCIM/Camera/my_video.mp4"; //change the location of your file!
    
    ImageView imageview_mini = (ImageView)findViewById(R.id.thumbnail_mini);
    ImageView imageview_micro = (ImageView)findViewById(R.id.thumbnail_micro);
    
    Bitmap bmThumbnail;
    
    
    
    bmThumbnail = ThumbnailUtils.createVideoThumbnail(filePath, Thumbnails.MINI_KIND);
    imageview_mini.setImageBitmap(bmThumbnail);
    

    Check this link