diff --git a/apps/mobile/app/(app)/(tabs)/home/settings.tsx b/apps/mobile/app/(app)/(tabs)/home/settings.tsx
index ce05edb..cab98a8 100644
--- a/apps/mobile/app/(app)/(tabs)/home/settings.tsx
+++ b/apps/mobile/app/(app)/(tabs)/home/settings.tsx
@@ -1,4 +1,8 @@
-import { atmosEnabled, dolbyAtmosSupported } from "@/lib/playback-capabilities"
+import {
+ atmosEnabled,
+ deviceDownloadQualities,
+ dolbyAtmosSupported,
+} from "@/lib/playback-capabilities"
import { Ionicons } from "@expo/vector-icons"
import { useAction, useMutation, useQuery } from "convex/react"
import { Image } from "expo-image"
@@ -25,7 +29,6 @@ import {
writeRememberedDownloadQuality,
} from "@/lib/downloads"
import {
- DOWNLOAD_QUALITIES,
DOWNLOAD_QUALITY_DETAILS,
DOWNLOAD_QUALITY_LABELS,
formatBytes,
@@ -508,7 +511,7 @@ function RememberedQualityCard() {
detail: string
}[] = [
{ value: null, label: "Ask every time", detail: "Choose when downloading" },
- ...DOWNLOAD_QUALITIES.map((quality) => ({
+ ...deviceDownloadQualities.map((quality) => ({
value: quality,
label: DOWNLOAD_QUALITY_LABELS[quality],
detail: DOWNLOAD_QUALITY_DETAILS[quality],
diff --git a/apps/mobile/contexts/downloads.tsx b/apps/mobile/contexts/downloads.tsx
index d16699f..45e2687 100644
--- a/apps/mobile/contexts/downloads.tsx
+++ b/apps/mobile/contexts/downloads.tsx
@@ -34,6 +34,7 @@ import {
writeRememberedDownloadQuality,
} from "@/lib/downloads"
import { loadPlaybackSongs } from "@/lib/playback-files"
+import { downloadQualitySupported } from "@/lib/playback-capabilities"
import type { ServerConfig } from "@/lib/server-config"
import { showError } from "@/lib/toast"
import { useThemeColors } from "@/lib/theme"
@@ -238,36 +239,44 @@ function DownloadQualityPopup({
>
{pending?.target.title}
- {pending?.response.options.map((option) => (
- onPick(option.quality, remember)}
- >
-
- {option.quality === "lossless" ||
- option.quality === "atmos" ? (
-
- ) : (
-
- {DOWNLOAD_QUALITY_LABELS[option.quality]}
+ {pending?.response.options
+ .filter((option) => downloadQualitySupported(option.quality))
+ .map((option) => (
+ onPick(option.quality, remember)}
+ >
+
+ {option.quality === "lossless" ||
+ option.quality === "atmos" ? (
+
+ ) : (
+
+ {DOWNLOAD_QUALITY_LABELS[option.quality]}
+
+ )}
+
+ {optionDetail(option, songCount)}
- )}
-
- {optionDetail(option, songCount)}
+
+
+ {option.estimated ? "~" : ""}
+ {formatBytes(option.bytes)}
-
-
- {option.estimated ? "~" : ""}
- {formatBytes(option.bytes)}
-
-
- ))}
+
+ ))}
Remember my choice
diff --git a/apps/mobile/lib/downloads.ts b/apps/mobile/lib/downloads.ts
index 4151d66..9d9df42 100644
--- a/apps/mobile/lib/downloads.ts
+++ b/apps/mobile/lib/downloads.ts
@@ -16,6 +16,7 @@ import {
type DownloadQuality,
} from "@otunes/convex/download-quality"
import { getAuthCookieHeader } from "@/lib/auth-cookies"
+import { downloadQualitySupported } from "@/lib/playback-capabilities"
import type { ServerConfig } from "@/lib/server-config"
const REMEMBERED_QUALITY_KEY = "otunes.download-quality"
@@ -298,9 +299,10 @@ export function downloadedCoverUri(url: string) {
export async function readRememberedDownloadQuality() {
try {
- return parseDownloadQuality(
+ const quality = parseDownloadQuality(
await AsyncStorage.getItem(REMEMBERED_QUALITY_KEY)
)
+ return quality && downloadQualitySupported(quality) ? quality : undefined
} catch {
return undefined
}
diff --git a/apps/mobile/lib/playback-capabilities.ts b/apps/mobile/lib/playback-capabilities.ts
index 9f4bd14..7bdb9a4 100644
--- a/apps/mobile/lib/playback-capabilities.ts
+++ b/apps/mobile/lib/playback-capabilities.ts
@@ -1,5 +1,10 @@
import { Platform } from "react-native"
+import {
+ DOWNLOAD_QUALITIES,
+ type DownloadQuality,
+} from "@otunes/convex/download-quality"
+
// Android Dolby decoder reports do not reliably indicate working Atmos playback.
export const dolbyAtmosSupported = Platform.OS === "ios"
@@ -7,3 +12,13 @@ export const dolbyAtmosSupported = Platform.OS === "ios"
export function atmosEnabled(user: { preferAtmos?: boolean }) {
return dolbyAtmosSupported && (user.preferAtmos ?? false)
}
+
+/** Whether this device may download in a quality. Android cannot download Atmos. */
+export function downloadQualitySupported(quality: DownloadQuality) {
+ return quality !== "atmos" || dolbyAtmosSupported
+}
+
+/** Download qualities this device offers, lowest first. */
+export const deviceDownloadQualities = DOWNLOAD_QUALITIES.filter(
+ downloadQualitySupported
+)