Search code examples
androidthumbnailsuniversal-image-loader

how to display video thumbnails using Universal Image Loader


I need to display video thumbnails using Universal Image Loader , any help pleaz, i can get the thumbnail bitmap from this

Bitmap b= ThumbnailUtils.createVideoThumbnail(
             "",MediaStore.Images.Thumbnails.MICRO_KIND);

but how display it in imageloader because if i display the bitmap the adapter will make the mobile slow,


Solution

  • You have two way :

    A: Use simple method to set adapter

    1. Please set bitmap in image using method setImageBitmap().
    2. If you want set bitmap in universal image downloader.
    3. Create a method in universal class

      public void setImageThumbnail(String videoPath, ImageView imgView) {
      
         Bitmap b=ThumbnailUtils.createVideoThumbnail(videoPath,MediaStore.Images.Thumbnails.MICRO_KIND);
         imgView.setImageBitmap(b);
      
      }
      
    4. use this method where you want.

    B :You can also use Lru-cache for adapter.

    1. Use worker thread to load bitmap.
    2. Create lru cache hashmap to store bitmap.
    3. For example please use below code:

    http://eclipsesource.com/blogs/2012/07/31/loading-caching-and-displaying-images-in-android-part-1/

    for more detail you can use below link: http://developer.android.com/training/displaying-bitmaps/process-bitmap.html

    It will help for you.