From 6e09b72caa0b411a1a759ae7fdde09d31823e102 Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Wed, 9 Jan 2019 20:13:31 +0100 Subject: [PATCH] Fix #355 --- .../com/otaliastudios/cameraview/CameraOptions.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraOptions.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraOptions.java index 8042c505..dc566960 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraOptions.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraOptions.java @@ -87,7 +87,7 @@ public class CameraOptions { exposureCorrectionSupported = params.getMinExposureCompensation() != 0 || params.getMaxExposureCompensation() != 0; - // Sizes + // Picture Sizes List sizes = params.getSupportedPictureSizes(); for (Camera.Size size : sizes) { int width = flipSizes ? size.height : size.width; @@ -95,6 +95,8 @@ public class CameraOptions { supportedPictureSizes.add(new Size(width, height)); supportedPictureAspectRatio.add(AspectRatio.of(width, height)); } + + // Video Sizes List vsizes = params.getSupportedVideoSizes(); if (vsizes != null) { for (Camera.Size size : vsizes) { @@ -103,6 +105,15 @@ public class CameraOptions { supportedVideoSizes.add(new Size(width, height)); supportedVideoAspectRatio.add(AspectRatio.of(width, height)); } + } else { + // StackOverflow threads seems to agree that if getSupportedVideoSizes is null, previews can be used. + List fallback = params.getSupportedPreviewSizes(); + for (Camera.Size size : fallback) { + int width = flipSizes ? size.height : size.width; + int height = flipSizes ? size.width : size.height; + supportedVideoSizes.add(new Size(width, height)); + supportedVideoAspectRatio.add(AspectRatio.of(width, height)); + } } }