fix: Fix CamcorderProfile get crash on Samsung devices (#1907)

This commit is contained in:
Marc Rousavy 2023-10-03 12:04:03 +02:00 committed by GitHub
parent 1cdc3d1d9c
commit 83c0cdb030
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@ import android.os.Build
import android.util.Size
private fun getMaximumVideoSize(cameraId: String): Size? {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
val profiles = CamcorderProfile.getAll(cameraId, CamcorderProfile.QUALITY_HIGH)
if (profiles != null) {
@ -23,6 +24,10 @@ private fun getMaximumVideoSize(cameraId: String): Size? {
}
return null
} catch (e: Throwable) {
// some Samsung phones just crash when trying to get the CamcorderProfile. Only god knows why.
return null
}
}
fun CameraCharacteristics.getVideoSizes(cameraId: String, format: Int): List<Size> {