Textureview获取Surface [英] Textureview get Surface
问题描述
我正在使用ExoPlayer库,该库需要一个Surface,但是我找不到任何方法来检索Textureview的基础Surface.有任何想法吗?
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?
Surfaceview为此提供了一种方法:
The Surfaceview has a method for that:
surfaceView.getHolder().getSurface()
还是TextureView中没有表面?
Or is there no surface in TextureView?
推荐答案
第一步是从 getSurfaceTexture()成员函数的TextureView
First step is to get the SurfaceTexture from the TextureView using the getSurfaceTexture() member function.
SurfaceTexture surfaceTexture = textureView.getSurfaceTexture();
然后从构造函数 Surface(SurfaceTexture表面纹理),它将接受您的TextureView对象中的表面纹理.
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);
有关更多信息,请查看此问题报告.它证实了通过按照我描述的方式构造Surface对象,可以在带有ExoPlayer的TextureView中使用Surface.
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.
这篇关于Textureview获取Surface的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!