1

I need to take a screenshot programmatically from a youtube video. Unfortunately the code usually used for taking screenshots (see partially below) only returns black rectangles.

webView.setDrawingCacheEnabled(true);
webViewScreenshot = Bitmap.createBitmap(webView.getDrawingCache());
webView.setDrawingCacheEnabled(false);
FOS = new FileOutputStream(file);
webViewScreenshot.compress(Bitmap.CompressFormat.JPEG, 100, FOS);
FOS.flush();
FOS.close();

If I push the respective buttons (Power & Volume Down) I get a screenshot which actually shows the YouTube video. The best information I got about that so far is that for the programmatic screenshot, the video gets rendered on the GPU and for the hardware screenshot, the screen actually freezes and completely renders everything.

Any suggestions on how I could combine the two?

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
tobyUCT
  • 137
  • 9
  • You could try the [Youtube API](http://stackoverflow.com/questions/2068344/how-do-i-get-a-youtube-video-thumbnail-from-the-youtube-api) to get images – OneCricketeer Apr 28 '16 at 15:37
  • The thumbnails are not what I am looking for, but thanks for the suggestion. – tobyUCT May 02 '16 at 06:01

0 Answers0