diff --git a/components/DownloadItem.tsx b/components/DownloadItem.tsx index dcb14128..befc34ca 100644 --- a/components/DownloadItem.tsx +++ b/components/DownloadItem.tsx @@ -66,7 +66,7 @@ export const DownloadItems: React.FC = ({ const [selectedAudioStream, setSelectedAudioStream] = useState(-1); const [selectedSubtitleStream, setSelectedSubtitleStream] = useState(0); - const [maxBitrate, setMaxBitrate] = useState({ + const [maxBitrate, setMaxBitrate] = useState(settings?.defaultBitrate ?? { key: "Max", value: undefined, }); @@ -194,10 +194,11 @@ export const DownloadItems: React.FC = ({ for (const item of items) { if (itemsNotDownloaded.length > 1) { - ({ mediaSource, audioIndex, subtitleIndex } = getDefaultPlaySettings( - item, - settings! - )); + const defaults = getDefaultPlaySettings(item, settings!); + mediaSource = defaults.mediaSource; + audioIndex = defaults.audioIndex; + subtitleIndex = defaults.subtitleIndex; + // Keep using the selected bitrate for consistency across all downloads } const res = await getStreamUrl({ diff --git a/components/settings/OtherSettings.tsx b/components/settings/OtherSettings.tsx index e05c14e4..2a102548 100644 --- a/components/settings/OtherSettings.tsx +++ b/components/settings/OtherSettings.tsx @@ -1,5 +1,6 @@ import { Platform } from "react-native"; import { ScreenOrientationEnum, useSettings } from "@/utils/atoms/settings"; +import { BitrateSelector, BITRATES } from "@/components/BitrateSelector"; import { BACKGROUND_FETCH_TASK, registerBackgroundFetchAsync, @@ -163,6 +164,32 @@ export const OtherSettings: React.FC = () => { title={t("home.settings.other.hide_libraries")} showArrow /> + + item.key} + titleExtractor={(item) => item.key} + selected={settings.defaultBitrate} + title={ + + + {settings.defaultBitrate?.key} + + + + } + label={t("home.settings.other.quality")} + onSelected={(defaultBitrate) => updateSettings({ defaultBitrate })} + /> + x.Type === "Audio" )?.Index; - // 4. Get default bitrate - const bitrate = BITRATES[0]; + // 4. Get default bitrate from settings or fallback to max + const bitrate = settings?.defaultBitrate ?? BITRATES[0]; return { defaultAudioIndex: diff --git a/utils/atoms/settings.ts b/utils/atoms/settings.ts index 91a54969..35688e03 100644 --- a/utils/atoms/settings.ts +++ b/utils/atoms/settings.ts @@ -11,6 +11,7 @@ import { BaseItemKind, ItemFilter, } from "@jellyfin/sdk/lib/generated-client"; +import { Bitrate, BITRATES } from "@/components/BitrateSelector"; import { apiAtom } from "@/providers/JellyfinProvider"; import { writeInfoLog } from "@/utils/log"; @@ -122,6 +123,7 @@ export type Settings = { marlinServerUrl?: string; openInVLC?: boolean; downloadQuality?: DownloadOption; + defaultBitrate?: Bitrate; libraryOptions: LibraryOptions; defaultAudioLanguage: CultureDto | null; playDefaultAudioTrack: boolean; @@ -168,6 +170,7 @@ const defaultValues: Settings = { marlinServerUrl: "", openInVLC: false, downloadQuality: DownloadOptions[0], + defaultBitrate: BITRATES[0], libraryOptions: { display: "list", cardStyle: "detailed", diff --git a/utils/jellyfin/getDefaultPlaySettings.ts b/utils/jellyfin/getDefaultPlaySettings.ts index 2ef7cd68..068d6058 100644 --- a/utils/jellyfin/getDefaultPlaySettings.ts +++ b/utils/jellyfin/getDefaultPlaySettings.ts @@ -92,10 +92,8 @@ export function getDefaultPlaySettings( } } - // 4. Get default bitrate - const bitrate = BITRATES.sort( - (a, b) => (b.value || Infinity) - (a.value || Infinity) - )[0]; + // 4. Get default bitrate from settings or fallback to max + const bitrate = settings.defaultBitrate ?? BITRATES[0]; return { item,