4

I m playing a video inside a framelayout and when i press button, i want to take a photo of that video frame and i want to save it to sdcard. How can i do that? Thanks in advance

mystery
  • 153
  • 1
  • 1
  • 14
  • 1
    Take a look at this thread: http://stackoverflow.com/questions/14557623/how-can-i-take-a-screenshot-of-a-video-in-android – Raymond P Apr 11 '13 at 13:55

1 Answers1

2

If by photo you mean a thumbnail then the following code could be of use to you:

int id = **"The Video's 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 then just have to link this code to a button press using the Android onClickListner. A simple example using a listener would be like this:

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 to the SD card you should take a look at this answer:

Android Save images to SQLite or SDCard or memory

Community
  • 1
  • 1
Brian Var
  • 6,029
  • 25
  • 114
  • 212
  • i dont play a video actually, i m playing another android device's cam so there is not a path or id to video – mystery Apr 12 '13 at 11:57