Compare commits

...

1 Commits

Author SHA1 Message Date
Mattia Iavarone 418f1ed662 Use onStopVideo callback for restoring preview 5 years ago
  1. 4
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java
  2. 9
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.java

@ -726,9 +726,8 @@ public class Camera2Engine extends CameraEngine implements ImageReader.OnImageAv
} }
@Override @Override
public void onVideoResult(@Nullable VideoResult.Stub result, @Nullable Exception exception) { protected void onStopVideo() {
boolean wasRecordingFullVideo = mVideoRecorder instanceof Full2VideoRecorder; boolean wasRecordingFullVideo = mVideoRecorder instanceof Full2VideoRecorder;
super.onVideoResult(result, exception);
if (wasRecordingFullVideo) { if (wasRecordingFullVideo) {
// We have to stop all repeating requests and restart them. // We have to stop all repeating requests and restart them.
try { try {
@ -739,6 +738,7 @@ public class Camera2Engine extends CameraEngine implements ImageReader.OnImageAv
throw createCameraException(e); throw createCameraException(e);
} }
} }
super.onStopVideo();
} }
//endregion //endregion

@ -1187,14 +1187,19 @@ public abstract class CameraEngine implements
mHandler.run(new Runnable() { mHandler.run(new Runnable() {
@Override @Override
public void run() { public void run() {
LOG.i("stopVideo", "executing.", "isTakingVideo?", isTakingVideo());
onStopVideo();
}
});
}
protected void onStopVideo() {
LOG.i("stopVideo", "executing.", "isTakingVideo?", isTakingVideo()); LOG.i("stopVideo", "executing.", "isTakingVideo?", isTakingVideo());
if (mVideoRecorder != null) { if (mVideoRecorder != null) {
mVideoRecorder.stop(false); mVideoRecorder.stop(false);
mVideoRecorder = null; mVideoRecorder = null;
} }
} }
});
}
@CallSuper @CallSuper
@Override @Override

Loading…
Cancel
Save