mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-21 05:10:24 +01:00
Added subtitle mode in options
This commit is contained in:
@@ -11,8 +11,8 @@ import {
|
|||||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
|
|
||||||
interface MediaContextType {
|
interface MediaContextType {
|
||||||
settings: any;
|
settings: Settings | null;
|
||||||
updateSettings: any;
|
updateSettings: (update: Partial<Settings>) => void;
|
||||||
user: UserDto | undefined;
|
user: UserDto | undefined;
|
||||||
cultures: CultureDto[];
|
cultures: CultureDto[];
|
||||||
}
|
}
|
||||||
@@ -69,6 +69,8 @@ export const MediaProvider = ({ children }: { children: ReactNode }) => {
|
|||||||
settings?.defaultSubtitleLanguage?.ThreeLetterISOLanguageName ||
|
settings?.defaultSubtitleLanguage?.ThreeLetterISOLanguageName ||
|
||||||
"";
|
"";
|
||||||
|
|
||||||
|
updatePayload.SubtitleMode = update?.subtitleMode;
|
||||||
|
|
||||||
console.log("updatePayload", updatePayload);
|
console.log("updatePayload", updatePayload);
|
||||||
|
|
||||||
updateUserConfiguration(updatePayload);
|
updateUserConfiguration(updatePayload);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { useSettings } from "@/utils/atoms/settings";
|
|
||||||
import { TouchableOpacity, View, ViewProps } from "react-native";
|
import { TouchableOpacity, View, ViewProps } from "react-native";
|
||||||
import * as DropdownMenu from "zeego/dropdown-menu";
|
import * as DropdownMenu from "zeego/dropdown-menu";
|
||||||
import { Text } from "../common/Text";
|
import { Text } from "../common/Text";
|
||||||
import { useMedia } from "./MediaContext";
|
import { useMedia } from "./MediaContext";
|
||||||
import { Switch } from "react-native-gesture-handler";
|
import { Switch } from "react-native-gesture-handler";
|
||||||
|
import { SubtitlePlaybackMode } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
|
||||||
interface Props extends ViewProps {}
|
interface Props extends ViewProps {}
|
||||||
|
|
||||||
@@ -11,9 +11,16 @@ export const SubtitleToggles: React.FC<Props> = ({ ...props }) => {
|
|||||||
const media = useMedia();
|
const media = useMedia();
|
||||||
const { settings, updateSettings } = media;
|
const { settings, updateSettings } = media;
|
||||||
const cultures = media.cultures;
|
const cultures = media.cultures;
|
||||||
|
|
||||||
if (!settings) return null;
|
if (!settings) return null;
|
||||||
|
|
||||||
|
const subtitleModes = [
|
||||||
|
SubtitlePlaybackMode.Default,
|
||||||
|
SubtitlePlaybackMode.Smart,
|
||||||
|
SubtitlePlaybackMode.OnlyForced,
|
||||||
|
SubtitlePlaybackMode.Always,
|
||||||
|
SubtitlePlaybackMode.None,
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
<Text className="text-lg font-bold mb-2">Subtitle</Text>
|
<Text className="text-lg font-bold mb-2">Subtitle</Text>
|
||||||
@@ -75,6 +82,51 @@ export const SubtitleToggles: React.FC<Props> = ({ ...props }) => {
|
|||||||
</DropdownMenu.Root>
|
</DropdownMenu.Root>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
<View
|
||||||
|
className={`
|
||||||
|
flex flex-row items-center space-x-2 justify-between bg-neutral-900 p-4
|
||||||
|
`}
|
||||||
|
>
|
||||||
|
<View className="flex flex-col shrink">
|
||||||
|
<Text className="font-semibold">Subtitle Mode</Text>
|
||||||
|
<Text className="text-xs opacity-50">
|
||||||
|
Subtitles are loaded based on the default and forced flags in the
|
||||||
|
embedded metadata. Language preferences are considered when
|
||||||
|
multiple options are available.
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
<DropdownMenu.Root>
|
||||||
|
<DropdownMenu.Trigger>
|
||||||
|
<TouchableOpacity className="bg-neutral-800 rounded-lg border-neutral-900 border px-3 py-2 flex flex-row items-center justify-between">
|
||||||
|
<Text>{settings?.subtitleMode || "Loading"}</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
</DropdownMenu.Trigger>
|
||||||
|
<DropdownMenu.Content
|
||||||
|
loop={true}
|
||||||
|
side="bottom"
|
||||||
|
align="start"
|
||||||
|
alignOffset={0}
|
||||||
|
avoidCollisions={true}
|
||||||
|
collisionPadding={8}
|
||||||
|
sideOffset={8}
|
||||||
|
>
|
||||||
|
<DropdownMenu.Label>Subtitle Mode</DropdownMenu.Label>
|
||||||
|
{subtitleModes?.map((l) => (
|
||||||
|
<DropdownMenu.Item
|
||||||
|
key={l}
|
||||||
|
onSelect={() => {
|
||||||
|
updateSettings({
|
||||||
|
subtitleMode: l,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DropdownMenu.ItemTitle>{l}</DropdownMenu.ItemTitle>
|
||||||
|
</DropdownMenu.Item>
|
||||||
|
))}
|
||||||
|
</DropdownMenu.Content>
|
||||||
|
</DropdownMenu.Root>
|
||||||
|
</View>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
className={`
|
className={`
|
||||||
flex flex-row items-center space-x-2 justify-between bg-neutral-900 p-4
|
flex flex-row items-center space-x-2 justify-between bg-neutral-900 p-4
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ import { useEffect } from "react";
|
|||||||
import * as ScreenOrientation from "expo-screen-orientation";
|
import * as ScreenOrientation from "expo-screen-orientation";
|
||||||
import { storage } from "../mmkv";
|
import { storage } from "../mmkv";
|
||||||
import { Platform } from "react-native";
|
import { Platform } from "react-native";
|
||||||
import { CultureDto } from "@jellyfin/sdk/lib/generated-client";
|
import {
|
||||||
|
CultureDto,
|
||||||
|
SubtitlePlaybackMode,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
|
||||||
export type DownloadQuality = "original" | "high" | "low";
|
export type DownloadQuality = "original" | "high" | "low";
|
||||||
|
|
||||||
@@ -69,6 +72,7 @@ export type Settings = {
|
|||||||
libraryOptions: LibraryOptions;
|
libraryOptions: LibraryOptions;
|
||||||
defaultSubtitleLanguage: CultureDto | null;
|
defaultSubtitleLanguage: CultureDto | null;
|
||||||
defaultAudioLanguage: CultureDto | null;
|
defaultAudioLanguage: CultureDto | null;
|
||||||
|
subtitleMode: SubtitlePlaybackMode;
|
||||||
showHomeTitles: boolean;
|
showHomeTitles: boolean;
|
||||||
defaultVideoOrientation: ScreenOrientation.OrientationLock;
|
defaultVideoOrientation: ScreenOrientation.OrientationLock;
|
||||||
forwardSkipTime: number;
|
forwardSkipTime: number;
|
||||||
@@ -101,6 +105,7 @@ const loadSettings = (): Settings => {
|
|||||||
},
|
},
|
||||||
defaultAudioLanguage: null,
|
defaultAudioLanguage: null,
|
||||||
defaultSubtitleLanguage: null,
|
defaultSubtitleLanguage: null,
|
||||||
|
subtitleMode: SubtitlePlaybackMode.Default,
|
||||||
showHomeTitles: true,
|
showHomeTitles: true,
|
||||||
defaultVideoOrientation: ScreenOrientation.OrientationLock.DEFAULT,
|
defaultVideoOrientation: ScreenOrientation.OrientationLock.DEFAULT,
|
||||||
forwardSkipTime: 30,
|
forwardSkipTime: 30,
|
||||||
|
|||||||
Reference in New Issue
Block a user