android get video thumbnail PATH, not Bitmap

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

Answers


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.


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

Need Your Help

how to avoid the refreshing of view1 while switching from view1 to view2 via Segue

iphone uiview segue ios5.1 uistoryboardsegue

I have 2 views and switching from view1 to view2 via a modal segue (full screen, cross dissolve).