Textureview get Surface

后端 未结 2 2018
刺人心
刺人心 2021-01-05 13:50

I am using the ExoPlayer Library, which expects a Surface, however i couldn\'t find any Method, which retrieves the underlying Surface of the Textureview. Any Ideas?

2条回答
  •  生来不讨喜
    2021-01-05 14:28

    First step is to get the SurfaceTexture from the TextureView using the getSurfaceTexture() member function.

    SurfaceTexture surfaceTexture = textureView.getSurfaceTexture();
    

    Then create the Surface object from the constructor Surface(SurfaceTexture surfaceTexture) that will accept the SurfaceTexture from your TextureView object.

    Surface surface = new Surface(surfaceTexture);
    

    For more information take a look at this issue report. It confirms that by constructing the Surface object in the manner I described it is possible to use the Surface from a TextureView with ExoPlayer.

提交回复
热议问题