So I'm trying to do a screen shot of a VideoView. I figured the easiest way would be:
videoView.setDrawingCacheEnabled(true);
Then when I need to take a screenshot:
Bitmap screenshot = videoView.getDrawingCache();
But for some reason the bitmap I get back is just black every time. Anyone had any success with this? I also tried:
Bitmap bitmap = Bitmap.createBitmap(videoView.getWidth(), videoView.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
videoView.draw(canvas);
But once again, this returns me a black image. I can see that the VideoView is hardly even documented in the Android javadocs. Any help?
Since API 10, you can use MediaMetadataRetriever to retrieve a frame at given time (in micro seconds). Here is a sample code:
From the docs for View#setDrawingCacheEnabled:
It's possible that the VideoView operates with hardware acceleration and is bypassing the caching mechanism. A good source dive might shed some light.
Edit - this post seems to clear some things up:
(VideoView is a child of SurfaceView)