开发者

android video thumbnails

开发者 https://www.devze.com 2023-01-07 15:28 出处:网络
I know that google does not have the official API to get video thumbnails under API 2.0 but how do I ac开发者_开发知识库cess the video thumbnails that are shown in the Gallery application. They are st

I know that google does not have the official API to get video thumbnails under API 2.0 but how do I ac开发者_开发知识库cess the video thumbnails that are shown in the Gallery application. They are stored somewhere ?


Using the path of the video you can get the thumbnail like this,

String tmppath = "/sdcard/temp.png";
String[] proj = { MediaStore.Video.Media._ID,
        MediaStore.Video.Media.DISPLAY_NAME,
        MediaStore.Video.Media.DATA };

Cursor cursor = managedQuery(
        MediaStore.Video.Media.EXTERNAL_CONTENT_URI, proj,
        MediaStore.Video.Media.DISPLAY_NAME + "=?",
        new String[] { tmppath.substring(tmppath.lastIndexOf("/")+1,
                tmppath.length()) }, null);
cursor.moveToFirst();
long id1 = cursor.getLong(cursor
        .getColumnIndex(MediaStore.Video.Media._ID));

ContentResolver crThumb = getContentResolver();
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 1;
bitmap = MediaStore.Video.Thumbnails.getThumbnail(crThumb,id1, MediaStore.Video.Thumbnails.MICRO_KIND, options);
0

精彩评论

暂无评论...
验证码 换一张
取 消