0

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.

Community
  • 1
  • 1
J.R.
  • 5,789
  • 11
  • 55
  • 78

1 Answers1

0

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);
Martin
  • 4,711
  • 4
  • 29
  • 37
  • Actually, I tried that, but a URI is not the same thing as a File path. I have just as much idea of how to turn my URI into a file path as I do about turning it into an ID. – J.R. Oct 09 '14 at 19:20
  • sure, but can't you ultimately get a file and/or blob out of that? – Martin Oct 10 '14 at 16:28