android get video thumbnail PATH, not Bitmap

前端 未结 2 1290
悲&欢浪女
悲&欢浪女 2021-01-12 08:39

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

MediaStore.Images.Thumbnails.queryMiniThumbnail
2条回答
  •  粉色の甜心
    2021-01-12 08:50

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

提交回复
热议问题