Question

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 !

Was it helpful?

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);

OTHER TIPS

you need to set data type in the intent intent.setDataAndType(Uri.parse(videoAddress), "video/3gpp");

and for thumbnail use can use,

Bitmap bm = ThumbnailUtils.createVideoThumbnail(path1.getPath()+"/"+filenames1[position], MediaStore.Images.Thumbnails.MINI_KIND);

You should change your intent type to this.

galleryIntent.setType("video/*")

By specifying the intent type, you would be able to see only videos from your gallery.

Once you get the Uri, you would need to query the content provider to get the path to the video file.

After retrieving the path to the video file, you can generate thumbnails of the video by using this code snippet.

Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(filePath,
                Thumbnails.MINI_KIND);

And then you can use this bitmap directly, or save the bitmap to a file and use the file instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top