mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-07-17 18:03:01 +01:00
feat(casting): replace H265 toggle with Chromecast profile selector
This commit is contained in:
@@ -1,18 +1,62 @@
|
|||||||
import { Switch, View } from "react-native";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
|
import { useMemo } from "react";
|
||||||
|
import { View } from "react-native";
|
||||||
import { useSettings } from "@/utils/atoms/settings";
|
import { useSettings } from "@/utils/atoms/settings";
|
||||||
|
import type { ChromecastProfileMode } from "@/utils/casting/capabilities";
|
||||||
|
import { Text } from "../common/Text";
|
||||||
import { ListGroup } from "../list/ListGroup";
|
import { ListGroup } from "../list/ListGroup";
|
||||||
import { ListItem } from "../list/ListItem";
|
import { ListItem } from "../list/ListItem";
|
||||||
|
import { PlatformDropdown } from "../PlatformDropdown";
|
||||||
|
|
||||||
|
const PROFILE_LABELS: Record<ChromecastProfileMode, string> = {
|
||||||
|
auto: "Automatic (recommended)",
|
||||||
|
"force-hevc": "Force HEVC / H265",
|
||||||
|
"force-h264": "Force H264",
|
||||||
|
};
|
||||||
|
|
||||||
export const ChromecastSettings: React.FC = ({ ...props }) => {
|
export const ChromecastSettings: React.FC = ({ ...props }) => {
|
||||||
const { settings, updateSettings } = useSettings();
|
const { settings, updateSettings } = useSettings();
|
||||||
|
|
||||||
|
const profileOptions = useMemo(
|
||||||
|
() => [
|
||||||
|
{
|
||||||
|
options: (
|
||||||
|
["auto", "force-hevc", "force-h264"] as ChromecastProfileMode[]
|
||||||
|
).map((mode) => ({
|
||||||
|
type: "radio" as const,
|
||||||
|
label: PROFILE_LABELS[mode],
|
||||||
|
value: mode,
|
||||||
|
selected: (settings.chromecastProfile ?? "auto") === mode,
|
||||||
|
onPress: () => updateSettings({ chromecastProfile: mode }),
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[settings.chromecastProfile, updateSettings],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View {...props}>
|
<View {...props}>
|
||||||
<ListGroup title={"Chromecast"}>
|
<ListGroup title={"Chromecast"}>
|
||||||
<ListItem title={"Enable H265 for Chromecast"}>
|
<ListItem
|
||||||
<Switch
|
title={"Profile"}
|
||||||
value={settings.enableH265ForChromecast}
|
subtitle={
|
||||||
onValueChange={(enableH265ForChromecast) =>
|
"Automatic picks codecs per device. Override only if needed."
|
||||||
updateSettings({ enableH265ForChromecast })
|
}
|
||||||
|
>
|
||||||
|
<PlatformDropdown
|
||||||
|
groups={profileOptions}
|
||||||
|
title={"Chromecast profile"}
|
||||||
|
trigger={
|
||||||
|
<View className='flex flex-row items-center justify-between py-1.5 pl-3'>
|
||||||
|
<Text className='mr-1 text-[#8E8D91]'>
|
||||||
|
{PROFILE_LABELS[settings.chromecastProfile ?? "auto"]}
|
||||||
|
</Text>
|
||||||
|
<Ionicons
|
||||||
|
name='chevron-expand-sharp'
|
||||||
|
size={18}
|
||||||
|
color='#5A5960'
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
|||||||
@@ -181,7 +181,6 @@ export type Settings = {
|
|||||||
jellyseerrServerUrl?: string;
|
jellyseerrServerUrl?: string;
|
||||||
useKefinTweaks: boolean;
|
useKefinTweaks: boolean;
|
||||||
hiddenLibraries?: string[];
|
hiddenLibraries?: string[];
|
||||||
enableH265ForChromecast: boolean;
|
|
||||||
/** Chromecast profile selection mode. "auto" detects per device. */
|
/** Chromecast profile selection mode. "auto" detects per device. */
|
||||||
chromecastProfile: ChromecastProfileMode;
|
chromecastProfile: ChromecastProfileMode;
|
||||||
/** Optional manual Chromecast video bitrate cap, in bits per second. */
|
/** Optional manual Chromecast video bitrate cap, in bits per second. */
|
||||||
@@ -276,7 +275,6 @@ export const defaultValues: Settings = {
|
|||||||
jellyseerrServerUrl: undefined,
|
jellyseerrServerUrl: undefined,
|
||||||
useKefinTweaks: false,
|
useKefinTweaks: false,
|
||||||
hiddenLibraries: [],
|
hiddenLibraries: [],
|
||||||
enableH265ForChromecast: false,
|
|
||||||
chromecastProfile: "auto",
|
chromecastProfile: "auto",
|
||||||
chromecastMaxBitrate: undefined,
|
chromecastMaxBitrate: undefined,
|
||||||
maxAutoPlayEpisodeCount: { key: "3", value: 3 },
|
maxAutoPlayEpisodeCount: { key: "3", value: 3 },
|
||||||
|
|||||||
Reference in New Issue
Block a user