-1

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,

Levon
  • 1,681
  • 2
  • 18
  • 40
user1796260
  • 297
  • 1
  • 4
  • 20
  • 1
    What have you tried so far? Are you comfortable with SurfaceViews and/or ExoPlayer video renderers? – Jon Adams Mar 18 '16 at 15:07
  • 1
    As far as SurfaceView goes this is a duplicate of http://stackoverflow.com/questions/27817577/ . I don't know if ExoPlayer has some nifty screen-grab feature though. – fadden Apr 27 '16 at 22:45

2 Answers2

0

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));
   ...

}

Ming C
  • 2,476
  • 2
  • 14
  • 8
-1

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();

}
BillHaggerty
  • 6,157
  • 10
  • 35
  • 68