How to get a photo of video playback in FrameLayout in Android?

I play the video inside the frame and when I click the button, I want to take a picture of this video frame, and I want to save it on the SD card. How can i do this? thanks in advance

+4
source share
1 answer

If you mean a sketch in a photograph, then the following code may come in handy:

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

You just need to associate this code with the click of a button using Android onClickListner . A simple example using a listener would be:

 final Button button = (Button) findViewById(R.id.button_id); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click } }); 

Finally, to save the thumbnail on the SD card, you should take a look at this answer:

Android Save images to SQLite or SDCard or to memory

+2
source

All Articles