I am trying to devise a way to access a playing video's current frame into a Bitmap context, without actually displaying the video on the screen (i.e. it is "playing" in memory, but not visible). Digging through the documentation, it seems one way would be through a SurfaceHolder interface. Does anyone know how to create a SurfaceHolder implementation that is not attached to the actual display? I have worked out a basic design, which would go something like this:
As you can see, the only problem with this method, is I must supply a "Context" to the SurfaceView constructor, such that it doesn't point to the actual screen. Any ideas what should go in there? Or am I way of track and there is an easier way to accomplish what I'm trying to do here?
Code:
MediaPlayer mPlayer = new MediaPlayer();
mPlayer.setDataSource( pathToSomeVideoFile );
int width = mPlayer.getVideoWidth();
int height = mPlayer.getVideoHeight();
Bitmap bMap = Bitmap.createBitmap( width, height, Bitmap.Config.ARGB_4444 );
Canvas c = new Canvas( bMap );
SurfaceView sView = new SurfaceView( ???? ); // What goes here?
SurfaceHolder sHolder = sView.getHolder();
mPlayer.setDisplay( sHolder );
mPlayer.prepare();
mPlayer.start();
// Then, to grab the current video frame:
sView.draw( c );
// bMap should now hold the current frame