在视频完成时从表面视图清除视频帧 [英] Clear video frame from surfaceview on video complete
问题描述
我创建了一个媒体播放器,可以在表面视图上播放视频.视频完成后,视频的最后一帧仍保留在表面上.我想从表面移除视频帧,因为经过一段时间的延迟,另一个视频开始了.
I have created a media player which plays video on the surface view. After completion of video the last frame of the video remains on the surface. I want to remove the video frame from the surface because after some delay another video starts.
视频的流程是:
现在:表面上的视频 -> 表面上的最后一个视频帧 -> 表面上的另一个视频.
但是需要的流程是:
要求:表面上的视频 -> 表面清晰(黑色)-> 表面上的另一个视频.
谁能帮忙解决这个问题.
can anyone help to solve this problem.
谢谢伊山耆那
推荐答案
基于 Fadden 的回答和 Andreimarinescu 的问题,这里是 API 16 及以下版本:
Building on Fadden's answer, and Andreimarinescu's question, here is a version for API 16 and below:
private void clearSurface(Surface surface) {
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, EGL14.EGL_OPENGL_ES2_BIT,
EGL10.EGL_NONE, 0, // placeholder for 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[]{
EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
EGL10.EGL_NONE
});
EGLSurface eglSurface = egl.eglCreateWindowSurface(display, config, surface,
new int[]{
EGL14.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);
}
相当粗糙,缺乏错误检查,但对我有用.
Pretty crude, lacks error checking, but it works for me.
这篇关于在视频完成时从表面视图清除视频帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!