diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java b/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java index e87e7bf7..88250b96 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java +++ b/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(