0

I am having an issue with while switching GLSurfaceView. I have a GLSurfaceView (connected with Camera) and I want to move it to another view , but when I am moving it it's losing its frames and showing blackScreen after switching. and when I am reconnecting it to Camera, it starts show my Camera but with delay.

Could any one please tell me solution to move it to another parent without losing its frames (because when I am reconnecting it its showing frames with 2-3 seconds delay).

Please find code written below : (Here VideoPanel (extends GLSurfaceView) is Frame provided by oovooSDK to show video)

                            final VideoPanel movingVideoView = parent1.getChildAt(0);

                            movingView.onPause();

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

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

for reconnecting :

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

I tried following methods also

        ((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
NehaK
  • 2,639
  • 1
  • 15
  • 31

1 Answers1

0

Camera is not proper release when your activity going to end.

If you are using a Surface view than release your camera in onSurfaceDestroy

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

    }

Also recommend a release your camera if it's not ever going to use.

protected void onDestroy(){
        if(camera!=null){
            camera.stopPreview();
            camera.setPreviewCallback(null);
            camera.release();
            camera = null;
        }
}
QuokMoon
  • 4,387
  • 4
  • 26
  • 50