Better video error handling

v2
Mattia Iavarone 6 years ago
parent 8b3e6c3a69
commit e2ce019112
  1. 11
      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
mCamera.unlock();
// 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