mirror of
https://github.com/streamyfin/streamyfin.git
synced 2025-08-20 18:37:18 +02:00
feat: Add default quality setting (#509)
This commit is contained in:
@@ -66,7 +66,7 @@ export const DownloadItems: React.FC<DownloadProps> = ({
|
|||||||
const [selectedAudioStream, setSelectedAudioStream] = useState<number>(-1);
|
const [selectedAudioStream, setSelectedAudioStream] = useState<number>(-1);
|
||||||
const [selectedSubtitleStream, setSelectedSubtitleStream] =
|
const [selectedSubtitleStream, setSelectedSubtitleStream] =
|
||||||
useState<number>(0);
|
useState<number>(0);
|
||||||
const [maxBitrate, setMaxBitrate] = useState<Bitrate>({
|
const [maxBitrate, setMaxBitrate] = useState<Bitrate>(settings?.defaultBitrate ?? {
|
||||||
key: "Max",
|
key: "Max",
|
||||||
value: undefined,
|
value: undefined,
|
||||||
});
|
});
|
||||||
@@ -194,10 +194,11 @@ export const DownloadItems: React.FC<DownloadProps> = ({
|
|||||||
|
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
if (itemsNotDownloaded.length > 1) {
|
if (itemsNotDownloaded.length > 1) {
|
||||||
({ mediaSource, audioIndex, subtitleIndex } = getDefaultPlaySettings(
|
const defaults = getDefaultPlaySettings(item, settings!);
|
||||||
item,
|
mediaSource = defaults.mediaSource;
|
||||||
settings!
|
audioIndex = defaults.audioIndex;
|
||||||
));
|
subtitleIndex = defaults.subtitleIndex;
|
||||||
|
// Keep using the selected bitrate for consistency across all downloads
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await getStreamUrl({
|
const res = await getStreamUrl({
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Platform } from "react-native";
|
import { Platform } from "react-native";
|
||||||
import { ScreenOrientationEnum, useSettings } from "@/utils/atoms/settings";
|
import { ScreenOrientationEnum, useSettings } from "@/utils/atoms/settings";
|
||||||
|
import { BitrateSelector, BITRATES } from "@/components/BitrateSelector";
|
||||||
import {
|
import {
|
||||||
BACKGROUND_FETCH_TASK,
|
BACKGROUND_FETCH_TASK,
|
||||||
registerBackgroundFetchAsync,
|
registerBackgroundFetchAsync,
|
||||||
@@ -163,6 +164,32 @@ export const OtherSettings: React.FC = () => {
|
|||||||
title={t("home.settings.other.hide_libraries")}
|
title={t("home.settings.other.hide_libraries")}
|
||||||
showArrow
|
showArrow
|
||||||
/>
|
/>
|
||||||
|
<ListItem
|
||||||
|
title="Default quality"
|
||||||
|
disabled={pluginSettings?.defaultBitrate?.locked}
|
||||||
|
>
|
||||||
|
<Dropdown
|
||||||
|
data={BITRATES}
|
||||||
|
disabled={pluginSettings?.defaultBitrate?.locked}
|
||||||
|
keyExtractor={(item) => item.key}
|
||||||
|
titleExtractor={(item) => item.key}
|
||||||
|
selected={settings.defaultBitrate}
|
||||||
|
title={
|
||||||
|
<TouchableOpacity className="flex flex-row items-center justify-between py-3 pl-3">
|
||||||
|
<Text className="mr-1 text-[#8E8D91]">
|
||||||
|
{settings.defaultBitrate?.key}
|
||||||
|
</Text>
|
||||||
|
<Ionicons
|
||||||
|
name="chevron-expand-sharp"
|
||||||
|
size={18}
|
||||||
|
color="#5A5960"
|
||||||
|
/>
|
||||||
|
</TouchableOpacity>
|
||||||
|
}
|
||||||
|
label={t("home.settings.other.quality")}
|
||||||
|
onSelected={(defaultBitrate) => updateSettings({ defaultBitrate })}
|
||||||
|
/>
|
||||||
|
</ListItem>
|
||||||
<ListItem
|
<ListItem
|
||||||
title={t("home.settings.other.disable_haptic_feedback")}
|
title={t("home.settings.other.disable_haptic_feedback")}
|
||||||
disabled={pluginSettings?.disableHapticFeedback?.locked}
|
disabled={pluginSettings?.disableHapticFeedback?.locked}
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ const useDefaultPlaySettings = (
|
|||||||
(x) => x.Type === "Audio"
|
(x) => x.Type === "Audio"
|
||||||
)?.Index;
|
)?.Index;
|
||||||
|
|
||||||
// 4. Get default bitrate
|
// 4. Get default bitrate from settings or fallback to max
|
||||||
const bitrate = BITRATES[0];
|
const bitrate = settings?.defaultBitrate ?? BITRATES[0];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
defaultAudioIndex:
|
defaultAudioIndex:
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
ItemFilter,
|
ItemFilter,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { Bitrate, BITRATES } from "@/components/BitrateSelector";
|
||||||
import { apiAtom } from "@/providers/JellyfinProvider";
|
import { apiAtom } from "@/providers/JellyfinProvider";
|
||||||
import { writeInfoLog } from "@/utils/log";
|
import { writeInfoLog } from "@/utils/log";
|
||||||
|
|
||||||
@@ -122,6 +123,7 @@ export type Settings = {
|
|||||||
marlinServerUrl?: string;
|
marlinServerUrl?: string;
|
||||||
openInVLC?: boolean;
|
openInVLC?: boolean;
|
||||||
downloadQuality?: DownloadOption;
|
downloadQuality?: DownloadOption;
|
||||||
|
defaultBitrate?: Bitrate;
|
||||||
libraryOptions: LibraryOptions;
|
libraryOptions: LibraryOptions;
|
||||||
defaultAudioLanguage: CultureDto | null;
|
defaultAudioLanguage: CultureDto | null;
|
||||||
playDefaultAudioTrack: boolean;
|
playDefaultAudioTrack: boolean;
|
||||||
@@ -168,6 +170,7 @@ const defaultValues: Settings = {
|
|||||||
marlinServerUrl: "",
|
marlinServerUrl: "",
|
||||||
openInVLC: false,
|
openInVLC: false,
|
||||||
downloadQuality: DownloadOptions[0],
|
downloadQuality: DownloadOptions[0],
|
||||||
|
defaultBitrate: BITRATES[0],
|
||||||
libraryOptions: {
|
libraryOptions: {
|
||||||
display: "list",
|
display: "list",
|
||||||
cardStyle: "detailed",
|
cardStyle: "detailed",
|
||||||
|
|||||||
@@ -92,10 +92,8 @@ export function getDefaultPlaySettings(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Get default bitrate
|
// 4. Get default bitrate from settings or fallback to max
|
||||||
const bitrate = BITRATES.sort(
|
const bitrate = settings.defaultBitrate ?? BITRATES[0];
|
||||||
(a, b) => (b.value || Infinity) - (a.value || Infinity)
|
|
||||||
)[0];
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
item,
|
item,
|
||||||
|
|||||||
Reference in New Issue
Block a user