prevent onVideoTaken listener from being called after a fatal error occured

pull/59/head
Tim H 8 years ago
parent a067fc2702
commit da61217f7b
  1. 16
      cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java

@ -195,6 +195,22 @@ class Camera1 extends CameraController {
cameraException = new CameraUnavailableException(
"Media server died. In this case, the application must release the" +
" Camera object and instantiate a new one.");
// if we were taking a video, it failed, too.
if (mIsCapturingVideo) {
if (mVideoFile != null) {
// delete potentially-broken video file
if (mVideoFile.exists()) {
mVideoFile.delete();
}
// ensure that endVideo() will not trigger the onVideoTaken listener
mVideoFile = null;
}
// tidy up a bit
endVideo();
}
}
else if (errorCode == CAMERA_ERROR_UNKNOWN) {
cameraException = new CameraConfigurationFailedException(

Loading…
Cancel
Save