1

Is there a way to take a screenshot of a video playing in video view. I searched on the forum but could not get the required info. I tried with

 Bitmap bitmap = Bitmap.createBitmap(this.view.getWidth(), this.view.getHeight(), Config.ARGB_8888);
            Canvas canvas = new Canvas(bitmap);
            view.draw(canvas);

and

mCustomVideoView.setDrawingCacheEnabled(true);
Bitmap videoView = mCustomVideoView.getDrawingCache(false);

But none of these methods were helpful.

Ankuj
  • 713
  • 3
  • 10
  • 27
  • Not sure, but you can simply ask Android for a thumbnail with ThumbnailUtils.createVideoThumbnail(); if you can point it to the video with a path... – Stefan de Bruijn Mar 04 '13 at 14:16
  • But my requirement is different. It is a sort of health monitor systems of an app where I need to take screenshot of what is playing. Whereas thumbnail will always give me same image – Ankuj Mar 04 '13 at 14:18
  • Then maybe this can help you? Seems to be a working way to take a screenshot http://stackoverflow.com/questions/2661536/how-to-programatically-take-a-screenshot-on-android – Stefan de Bruijn Mar 04 '13 at 14:22
  • @Ankuj Are you asking to get the thumbnail for the video view. – Janmejoy Mar 04 '13 at 14:45
  • yes janmejoy, I am trying to get a thumbnail of video view – Ankuj Mar 04 '13 at 15:01
  • @Ankuj- Did you able to get this solved! I also stuck with this problem. – Prabhjot Singh Oct 29 '14 at 15:44

1 Answers1

0

Just make it with that:

videoview.buildDrawingCache();

Bitmap bitmap = yourvideoview.getDrawingCache(); 
 java.io.ByteArrayOutputStream stream=new java.io.ByteArrayOutputStream();  

bitmap.compress(Bitmap.CompressFormat.WEBP, 90, stream); 

byte[] videoByteArray=stream.toByteArray(); String video_str = Base64.encodeToString(videoByteArray, 0);

The output is the String video_str and the Bitmap bitmap.

Vega
  • 27,856
  • 27
  • 95
  • 103
Hoppel87
  • 1
  • 2