Use onStopVideo callback for restoring preview

stop-video
Mattia Iavarone 5 years ago
parent 0c04d6405c
commit 418f1ed662
  1. 4
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java
  2. 13
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.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

@ -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) {

Loading…
Cancel
Save