I have a problem with creating Thumbnail from mp4 file which is in assets folder. Try to enter different asset`s path but no effect. How can I fix it?
That`s my piece of adapter code:
VideoEntry video = videos.get(position);
holder.txtTitle.setText(video.getTitle());
holder.imgIcon.setImageBitmap(ThumbnailUtils.createVideoThumbnail("file:///android_asset/videos/Core/Superman.mp4", Thumbnails.MICRO_KIND));
What is wrong?
Solution:
AssetManager am = getAssets();
InputStream ims = am.open("images/" + category + "/" + item.replace(" ", "_").replace(".mp4", ".png").toLowerCase());
Drawable d = Drawable.createFromStream(ims, null);
holder.imgIcon.setImageDrawable(d);
ThumbnailUtils.createVideoThumbnail()just queries an existing thumbnail fromMediaStoreor forcesMediaStoreto create it if it doesn’t exist. This means that you can’t create a thumbnail for a video file that isn’t available forMediaStore, as it’s an asset of your application and not an actual file on the SD card. You can extract your file to SD card or just provide a thumbnail created by yourself in another application. Hope this helps.