Better video error handling

pull/360/head
Mattia Iavarone 6 years ago
parent 1b5a20b034
commit 97c839af87
  1. 9
      cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java
  2. 1
      cameraview/src/main/java/com/otaliastudios/cameraview/FullVideoRecorder.java

@ -642,8 +642,15 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera
videoResult.videoBitRate = mVideoBitRate;
videoResult.audioBitRate = mAudioBitRate;
// Initialize the media recorder
// Unlock the camera and start recording.
try {
mCamera.unlock();
} catch (Exception e) {
// If this failed, we are unlikely able to record the video.
// Dispatch an error.
onVideoResult(null);
return;
}
mVideoRecorder = new FullVideoRecorder(videoResult, Camera1.this, mCamera, mCameraId);
mVideoRecorder.start();
}

@ -109,6 +109,7 @@ class FullVideoRecorder extends VideoRecorder {
mMediaRecorder.stop();
} catch (Exception e) {
// This can happen if stopVideo() is called right after takeVideo(). We don't care.
mResult = null;
LOG.w("stop:", "Error while closing media recorder. Swallowing", e);
}
mMediaRecorder.release();

Loading…
Cancel
Save