extend error handling for the CameraView

pull/59/merge^2
Tim H 7 years ago
parent d9141b6cdf
commit c253c4dc2b
  1. 20
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java

@ -557,9 +557,10 @@ public class CameraView extends FrameLayout {
return;
}
}
LOG.e("Permission error:", "When the session type is set to video,",
"the RECORD_AUDIO permission should be added to the app manifest file.");
throw new IllegalStateException(CameraLogger.lastMessage);
CameraException cameraException = new CameraUnavailableException("Permission " +
"error: When the session type is set to video, the RECORD_AUDIO " +
"permission should be added to the app manifest file.");
mCameraCallbacks.onError(cameraException);
} catch (PackageManager.NameNotFoundException e) {
// Not possible.
}
@ -1002,7 +1003,11 @@ public class CameraView extends FrameLayout {
*/
public void setJpegQuality(int jpegQuality) {
if (jpegQuality <= 0 || jpegQuality > 100) {
throw new IllegalArgumentException("JPEG quality should be > 0 and <= 100");
IllegalArgumentException illegalArgumentException = new
IllegalArgumentException("JPEG quality should be > 0 and <= 100");
CameraException cameraException = new CameraConfigurationFailedException("Could not" +
" set JpegQuality", illegalArgumentException);
mCameraCallbacks.onError(cameraException);
}
mJpegQuality = jpegQuality;
}
@ -1165,15 +1170,16 @@ public class CameraView extends FrameLayout {
* so callers should ensure they have appropriate permissions to write to the file.
* Recording will be automatically stopped after durationMillis, unless
* {@link #stopCapturingVideo()} is not called meanwhile.
* Triggers error handler, if durationMillis is less than 500 milliseconds.
*
* @param file a file where the video will be saved
* @param durationMillis video max duration
*
* @throws IllegalArgumentException if durationMillis is less than 500 milliseconds
*/
public void startCapturingVideo(File file, long durationMillis) {
if (durationMillis < 500) {
throw new IllegalArgumentException("Video duration can't be < 500 milliseconds");
CameraException cameraException = new CapturingVideoFailedException("Video duration" +
" can't be < 500 milliseconds");
mCameraCallbacks.onError(cameraException);
}
startCapturingVideo(file);
mUiHandler.postDelayed(new Runnable() {

Loading…
Cancel
Save