I'm playing some videos using ExoPlayer and I'd like to get the current picture displayed on my SurfaceView, how can I make it?
Thanks,
I'm playing some videos using ExoPlayer and I'd like to get the current picture displayed on my SurfaceView, how can I make it?
Thanks,
If you use SurfaceView, you can not get the screenshot. However you can use a TextureView to play your video, then you can get screenshot from TextureView.
Here is an sample code to use TextureView, on its onSurfaceTextureAvailable() callback you can get a SurfaceTexture, then you can use this SurfaceTexture to create a Surface for ExoPlayer
player = ...
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
...
player.setSurface(new Surface(mSurfaceTexture));
...
}
Not Tested, taken from :How to convert View to Bitmap in android?
Changed input param to be more generic.
protected Bitmap ConvertToBitmap(View layout) {
layout.setDrawingCacheEnabled(true);
layout.buildDrawingCache();
return layout.getDrawingCache();
}