Android: Is it possible to display video thumbnails?
Explains that each video exposes it's thumbnails for us to use, so long as you have a video ID.
When I look for how to get the video's ID, I see a lot of things about Cursors, which I am not using (at least not directly, Intent.ACTION_GET_CONTENT might be using one).
Given this, how would I go about finding the ID (and subsequently the thumbnail)? Can I initialize a cursor with the URI I have? Can I somehow bypass the cursor entirely?
Edit: My URI looks something like: content://media/external/video/media/68. Which is not the same as a file path (so I can't just generate thumbnails, when I try, I get null). If anyone knows how to go from URI to file path, let me know that, too.
Something like this will create thumbnails for video (mp4) files:
File folder = new File(path.toString());
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
String mp4 = path.toString() + "/" + availableFiles[0];
filePaths.set(7,mp4);
mmr.setDataSource(mp4);
Bitmap thumb = ThumbnailUtils.createVideoThumbnail(mp4,
MediaStore.Images.Thumbnails.MINI_KIND);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.