android - Clean SurfaceTexture with black rect -


i'm using exoplayer , gl surfacetexture (from textureview) display video. i'm reusing same surface among video play.

i release player , instantiate new one. when surfacetexture displayed second time, it display old texture last video until player begin play , fill surface black.

i'm looking way draw black rect fill surface black, unable achieve this.

using @fadden link on grafika, i've made own script clear surface. it's compatible api 16.

gist

/**  * clear given surface texture attachign gl context , clearing surface.  * @param texture valid surfacetexture  */ private void clearsurface(surfacetexture texture) {     if(texture == null){         return;     }      egl10 egl = (egl10) eglcontext.getegl();     egldisplay display = egl.eglgetdisplay(egl10.egl_default_display);     egl.eglinitialize(display, null);      int[] attriblist = {             egl10.egl_red_size, 8,             egl10.egl_green_size, 8,             egl10.egl_blue_size, 8,             egl10.egl_alpha_size, 8,             egl10.egl_renderable_type, egl10.egl_window_bit,             egl10.egl_none, 0,      // placeholder recordable [@-3]             egl10.egl_none     };     eglconfig[] configs = new eglconfig[1];     int[] numconfigs = new int[1];     egl.eglchooseconfig(display, attriblist, configs, configs.length, numconfigs);     eglconfig config = configs[0];     eglcontext context = egl.eglcreatecontext(display, config, egl10.egl_no_context, new int[]{             12440, 2,             egl10.egl_none     });     eglsurface eglsurface = egl.eglcreatewindowsurface(display, config, texture,             new int[]{                     egl10.egl_none             });      egl.eglmakecurrent(display, eglsurface, eglsurface, context);     gles20.glclearcolor(0, 0, 0, 1);     gles20.glclear(gles20.gl_color_buffer_bit);     egl.eglswapbuffers(display, eglsurface);     egl.egldestroysurface(display, eglsurface);     egl.eglmakecurrent(display, egl10.egl_no_surface, egl10.egl_no_surface,             egl10.egl_no_context);     egl.egldestroycontext(display, context);     egl.eglterminate(display); } 

Comments

Popular posts from this blog

python 3 IndexError: list index out of range -

android - How to save instance state of selected radiobutton on menu -

IF statement in MySQL trigger -