Textureview get Surface

半世苍凉 提交于 2019-12-07 02:49:14

问题


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?

The Surfaceview has a method for that:

surfaceView.getHolder().getSurface()

Or is there no surface in TextureView?


回答1:


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.




回答2:


You can also now in the new versions add an "AnalyticsListener" to the "SimpleExoPlayer" instance, and implement the method "onRenderedFirstFrame" which has the surface as one of its parameters.



来源:https://stackoverflow.com/questions/30971534/textureview-get-surface

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!