开发者

android video thumbnails

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜