From a612eb9d3872c475fc5167925a36fa5f4b74d3e9 Mon Sep 17 00:00:00 2001 From: Romick2005 <17779660+Romick2005@users.noreply.github.com> Date: Tue, 12 Dec 2023 12:15:10 +0200 Subject: [PATCH] fix: Fix `NoSuchElementException` in `getRecommendedBitRate` (#2266) * Remove unused hasConstants method. Do no thrown error on minBy call when filterd videoProfiles contains zero items. * Remove not related to the fix changes. --- .../camera/extensions/RecordingSession+getRecommendedBitRate.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/android/src/main/java/com/mrousavy/camera/extensions/RecordingSession+getRecommendedBitRate.kt b/package/android/src/main/java/com/mrousavy/camera/extensions/RecordingSession+getRecommendedBitRate.kt index 5fa016b..9a4984b 100644 --- a/package/android/src/main/java/com/mrousavy/camera/extensions/RecordingSession+getRecommendedBitRate.kt +++ b/package/android/src/main/java/com/mrousavy/camera/extensions/RecordingSession+getRecommendedBitRate.kt @@ -31,7 +31,7 @@ fun RecordingSession.getRecommendedBitRate(fps: Int, codec: VideoCodec, hdr: Boo if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { val profiles = CamcorderProfile.getAll(cameraId, quality) if (profiles != null) { - val best = profiles.videoProfiles.filterNotNull().minBy { + val best = profiles.videoProfiles.filterNotNull().minByOrNull { abs(it.width * it.height - targetResolution.width * targetResolution.height) }