How to get video finger nails from a raw video folder on Android

in my application I need to display the thumb nail of the video, which is stored in the res / raw folder. I was looking for him. I get the following code.

int id = **"The Video ID"**
ImageView iv = (ImageView ) convertView.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.setImageBitmap(curThumb);

With this code, I get a thumb from the SD card. but the video from the res / raw folder doesn’t show the thumb in it. I tried a lot of time, but I could not find a solution. I tried as follows.

I create an array and save the resource identifier (Ex:) int[] videoid={R.raw.vi1,...}and place the identifier inMediaStore.Video.Thumbnails.getThumbnail(crThumb, videoid[position], MediaStore.Video.Thumbnails.MICRO_KIND, options);.

Please help me. thanks in advance.

+5
source share
2 answers

You can try to get some kind of frame from your video like this:

    Uri  videoURI = Uri.parse("android.resource://" + getPackageName() +"/"
            +R.raw.cashword_video);
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    retriever.setDataSource(this, videoURI);
    Bitmap bitmap = retriever
          .getFrameAtTime(100000,MediaMetadataRetriever.OPTION_PREVIOUS_SYNC);
    Drawable drawable = new BitmapDrawable(getResources(), bitmap);
+14

res/raw Android Media Content Provider, .

SD - ThumbnailUtils.createVideoThumbnail ( Android 2.2 )

+1

All Articles