fix: Fix AVAudioSession not allowing background music playback (#155)
* Set category always if different * rename org * Fix video format sorting * fix format filtering * Update AVAudioSession+setCategoryIfNotSet.swift * upgrade all dependencies * Also run dependabot for JS codebase * Update MediaPage.tsx * Use typescript 4.2.4 * Also run TS in check-all * Downgrade typescript to 4.2.3 * f * recreate lockfiles * docs: Revert package.json changes * revert all package.json changes * Update Podfile.lock * bump all dependencies, pin typescript to 4.2.4 * Downgrade react-native-navigation for now * upgrade to later snapshot * Update yarn.lock * remove yeet
This commit is contained in:
@@ -21,11 +21,17 @@ export const sortDevices = (left: CameraDevice, right: CameraDevice): number =>
|
||||
|
||||
const leftHasWideAngle = left.devices.includes('wide-angle-camera');
|
||||
const rightHasWideAngle = right.devices.includes('wide-angle-camera');
|
||||
if (leftHasWideAngle) leftPoints += 5;
|
||||
if (rightHasWideAngle) rightPoints += 5;
|
||||
if (leftHasWideAngle) leftPoints += 2;
|
||||
if (rightHasWideAngle) rightPoints += 2;
|
||||
|
||||
if (left.devices.length > right.devices.length) leftPoints += 3;
|
||||
if (right.devices.length > left.devices.length) rightPoints += 3;
|
||||
// telephoto cameras often have very poor quality.
|
||||
const leftHasTelephoto = left.devices.includes('telephoto-camera');
|
||||
const rightHasTelephoto = right.devices.includes('telephoto-camera');
|
||||
if (leftHasTelephoto) leftPoints -= 2;
|
||||
if (rightHasTelephoto) rightPoints -= 2;
|
||||
|
||||
if (left.devices.length > right.devices.length) leftPoints += 1;
|
||||
if (right.devices.length > left.devices.length) rightPoints += 1;
|
||||
|
||||
return rightPoints - leftPoints;
|
||||
};
|
||||
@@ -46,14 +52,22 @@ export const sortFormats = (left: CameraDeviceFormat, right: CameraDeviceFormat)
|
||||
rightPoints = 0;
|
||||
|
||||
// we downscale the points so much that we are in smaller number ranges for future calculations
|
||||
// e.g. for 4k (4096), this adds 4 points.
|
||||
leftPoints += Math.round(left.photoWidth / 1000);
|
||||
rightPoints += Math.round(right.photoWidth / 1000);
|
||||
// e.g. for 4k (4096), this adds 8 points.
|
||||
leftPoints += Math.round(left.photoWidth / 500);
|
||||
rightPoints += Math.round(right.photoWidth / 500);
|
||||
// e.g. for 4k (4096), this adds 8 points.
|
||||
if (left.videoWidth != null && right.videoWidth != null) {
|
||||
leftPoints += Math.round(left.videoWidth / 500);
|
||||
rightPoints += Math.round(right.videoWidth / 500);
|
||||
}
|
||||
|
||||
// we downscale the points here as well, so if left has 16:9 and right has 21:9, this roughly
|
||||
// adds 5 points. If the difference is smaller, e.g. 16:9 vs 17:9, this roughly adds a little
|
||||
// bit over 1 point, just enough to overrule the FPS below.
|
||||
const leftAspectRatioDiff = left.photoHeight / left.photoWidth - SCREEN_ASPECT_RATIO;
|
||||
const rightAspectRatioDiff = right.photoHeight / right.photoWidth - SCREEN_ASPECT_RATIO;
|
||||
leftPoints -= Math.abs(leftAspectRatioDiff) * 50;
|
||||
rightPoints -= Math.abs(rightAspectRatioDiff) * 50;
|
||||
leftPoints -= Math.abs(leftAspectRatioDiff) * 10;
|
||||
rightPoints -= Math.abs(rightAspectRatioDiff) * 10;
|
||||
|
||||
return rightPoints - leftPoints;
|
||||
};
|
||||
|
Reference in New Issue
Block a user