7

Is it possible to get the video thumbnail PATH, not Bitmap object itself? I'm aware of method

MediaStore.Images.Thumbnails.queryMiniThumbnail

but since I use my own Bitmap caching mechanism I want to have the path to video thumbnail rather than the Bitmap object itself. This method returns Bitmap object, not path. Thanks

cubesoft
  • 3,396
  • 7
  • 47
  • 91

2 Answers2

6

First get the video file URL and then use below query.

Sample Code:

private static final String[] VIDEOTHUMBNAIL_TABLE = new String[] {
    Video.Media._ID, // 0
    Video.Media.DATA, // 1 from android.provider.MediaStore.Video
    };

Uri videoUri = MediaStore.Video.Thumbnails.getContentUri("external");

cursor c = cr.query(videoUri, VIDEOTHUMBNAIL_TABLE, where, 
           new String[] {filepath}, null);

if ((c != null) && c.moveToFirst()) {
  VideoThumbnailPath = c.getString(1);
}

VideoThumbnailPath, should have video thumbnail path. Hope it help's.

ישו אוהב אותך
  • 26,433
  • 11
  • 70
  • 92
Munish Katoch
  • 517
  • 3
  • 6
2

Get Video thumbnail path from video_id:

public static String getVideoThumbnail(Context context, int videoID) {
        try {
            String[] projection = {
                    MediaStore.Video.Thumbnails.DATA,
            };
            ContentResolver cr = context.getContentResolver();
            Cursor cursor = cr.query(
                    MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI,
                    projection, 
                    MediaStore.Video.Thumbnails.VIDEO_ID + "=?", 
                    new String[] { String.valueOf(videoID) }, 
                    null);
            cursor.moveToFirst();
            return cursor.getString(0);
        } catch (Exception e) {
        }
        return null;
    }
Ravindra Kushwaha
  • 7,428
  • 13
  • 49
  • 95
tuantv.dev
  • 78
  • 7