Search code examples
androidvideogallerythumbnailsvideo-thumbnails

Unable to set Thumbnail of a video to ImageView after getting its path


I thought that the following code will set the Thumbnail to the ImageView. I have Log the path & its correct & dont know what is missing. I am not getting any error but its thumbnail is not set by this code :

imgFile = new File(Path.pathvideoa);
        Bitmap bm = ThumbnailUtils.createVideoThumbnail(
                imgFile.getAbsolutePath(),
                MediaStore.Video.Thumbnails.MINI_KIND);
Log.i(Path.pathvideoa, "" + Path.pathvideoa);
ivA.setImageBitmap(bm);

where, imgFile is the object of class File & ivA is the ImageView

Thanks in advance !


Solution

  • use the below code

     galleryIntent.setType("video/*");  
    
    Bitmap bitmap =ThumbnailUtils.createVideoThumbnail(Environment.getExternalStorageDirectory() + "/video.mp4",MediaStore.Video.Thumbnails.MINI_KIND);
    ImageView iv = (ImageView) findViewById(R.id.thumb);
    iv.setImageBitmap(bitmap);