how to get unique ID of Video
In my application I'm trying to display the list of videos in a list view in one Activity
and I'm trying to display the thumbnail of selected video in another Activity
for I got a code to display the thumbnail in ImageView
,
iv = (ImageView)findViewById(R.id.imagePreview);
ContentResolver crThumb = getContentResolver();
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 1;
Bitmap curThumb =开发者_运维知识库 MediaStore.Video.Thumbnails.getThumbnail(crThumb, id, MediaStore.Video.Thumbnails.MICRO_KIND, options);
iv.setScaleType(ScaleType.CENTER_CROP);
iv.setImageBitmap(curThumb);
in this it displays the thumbnail only if I specify a integer value for id
in
Bitmap curThumb = MediaStore.Video.Thumbnails.getThumbnail(crThumb, id, MediaStore.Video.Thumbnails.MICRO_KIND, options);
but what I want is to get the id
value for selected video so that I can display it new Activity
as I wish.
Thanks.
String[] projection = { BaseColumns._ID, MediaColumns.DATA };
Cursor cursor = managedQuery(data, projection, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndexOrThrow(BaseColumns._ID);
int id = cursor.getInt(columnIndex);
This code will help you, "data" is the uri of selected video
Try This: Detail Click Here
int id = cursor.getInt(cursor.getColumnIndex(MediaStore.Video.Media._ID));
String[] thumbColumns = { MediaStore.Video.Thumbnails.DATA,
MediaStore.Video.Thumbnails.VIDEO_ID};
Cursor thumbCursor = managedQuery(MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI,
thumbColumns, MediaStore.Video.Thumbnails.VIDEO_ID + "=" + id, null, null);
if (thumbCursor.moveToFirst()) {
Log.v("VideoGallery",thumbCursor.getColumnIndex(MediaStore.Video.Thumbnails.DATA));
}
精彩评论