From 418f1ed662b0769946a5168b8b37f65f49fe4a55 Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Mon, 12 Aug 2019 18:51:31 +0200 Subject: [PATCH] Use onStopVideo callback for restoring preview --- .../cameraview/engine/Camera2Engine.java | 4 ++-- .../cameraview/engine/CameraEngine.java | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java index 2b471bf7..2bff887e 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java @@ -726,9 +726,8 @@ public class Camera2Engine extends CameraEngine implements ImageReader.OnImageAv } @Override - public void onVideoResult(@Nullable VideoResult.Stub result, @Nullable Exception exception) { + protected void onStopVideo() { boolean wasRecordingFullVideo = mVideoRecorder instanceof Full2VideoRecorder; - super.onVideoResult(result, exception); if (wasRecordingFullVideo) { // We have to stop all repeating requests and restart them. try { @@ -739,6 +738,7 @@ public class Camera2Engine extends CameraEngine implements ImageReader.OnImageAv throw createCameraException(e); } } + super.onStopVideo(); } //endregion diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.java b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.java index 8a05f7d3..2a535a97 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.java @@ -1188,14 +1188,19 @@ public abstract class CameraEngine implements @Override public void run() { LOG.i("stopVideo", "executing.", "isTakingVideo?", isTakingVideo()); - if (mVideoRecorder != null) { - mVideoRecorder.stop(false); - mVideoRecorder = null; - } + onStopVideo(); } }); } + protected void onStopVideo() { + LOG.i("stopVideo", "executing.", "isTakingVideo?", isTakingVideo()); + if (mVideoRecorder != null) { + mVideoRecorder.stop(false); + mVideoRecorder = null; + } + } + @CallSuper @Override public void onVideoResult(@Nullable VideoResult.Stub result, @Nullable Exception exception) {