【问题标题】:GLSurfaceView switching issueGLSurfaceView 切换问题
【发布时间】:2016-11-15 08:23:14
【问题描述】:

我在切换 GLSurfaceView 时遇到问题。我有一个 GLSurfaceView (与相机连接),我想将它移动到另一个视图,但是当我移动它时,它会丢失帧并在切换后显示 blackScreen。当我将它重新连接到相机时,它开始显示我的相机,但有延迟。

谁能告诉我解决方案,将它移动到另一个父母而不丢失它的帧(因为当我重新连接它时,它的显示帧延迟 2-3 秒)。

请找到下面写的代码: (这里VideoPanel(扩展GLSurfaceView)是oovooSDK提供的Frame用来显示视频)

                            final VideoPanel movingVideoView = parent1.getChildAt(0);

                            movingView.onPause();

                            parent1.removeView(movingView);
                            parent2.addView(movingView);

                            movingView.onResume();
                            movingView.requestRender();

重新连接:

                            application.unbindVideoPanel(videoView.userId, videoView.videoRender);
                            application.unbindVideoPanel(videoView.userId, videoView.videoRender);
                            // this methods shows delay of 2-3 seconds for binding view again

我也尝试了以下方法

        ((VideoPanel) videoView.videoRender).setPreserveEGLContextOnPause(true);
        // to save context when paused
((VideoPanel)videoView.videoRender).setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); // to render frame again when requestRender is called

【问题讨论】:

    标签: android glsurfaceview videochat oovoo


    【解决方案1】:

    当您的活动即将结束时,相机未正确释放。

    如果您使用的是 Surface 视图,则在 onSurfaceDestroy 中释放您的相机

    public void surfaceDestroyed(SurfaceHolder holder) {
            if(camera!=null){
                camera.stopPreview();
                camera.setPreviewCallback(null);
                camera.release();
                camera = null;
            }
    
        }
    

    如果您的相机永远不会使用,也建议您释放它。

    protected void onDestroy(){
            if(camera!=null){
                camera.stopPreview();
                camera.setPreviewCallback(null);
                camera.release();
                camera = null;
            }
    }
    

    【讨论】:

    • 我想你没有理解我的问题.. :/
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-31
    • 2013-12-21
    相关资源
    最近更新 更多