Merge branch 'feat/switch-players' into develop

This commit is contained in:
Fredrik Burmester
2025-03-03 15:18:20 +01:00
38 changed files with 689 additions and 197 deletions

View File

@@ -1,5 +1,5 @@
import { Platform } from "react-native";
import { ScreenOrientationEnum, useSettings } from "@/utils/atoms/settings";
import { ScreenOrientationEnum, useSettings, VideoPlayer } from "@/utils/atoms/settings";
import { BitrateSelector, BITRATES } from "@/components/BitrateSelector";
import {
BACKGROUND_FETCH_TASK,
@@ -7,9 +7,7 @@ import {
unregisterBackgroundFetchAsync,
} from "@/utils/background-tasks";
import { Ionicons } from "@expo/vector-icons";
const BackgroundFetch = !Platform.isTV
? require("expo-background-fetch")
: null;
const BackgroundFetch = !Platform.isTV ? require("expo-background-fetch") : null;
import * as ScreenOrientation from "@/packages/expo-screen-orientation";
const TaskManager = !Platform.isTV ? require("expo-task-manager") : null;
import { useRouter } from "expo-router";
@@ -22,6 +20,7 @@ import { ListItem } from "../list/ListItem";
import { useTranslation } from "react-i18next";
import DisabledSetting from "@/components/settings/DisabledSetting";
import Dropdown from "@/components/common/Dropdown";
import { isNumber } from "lodash";
export const OtherSettings: React.FC = () => {
const router = useRouter();
@@ -84,10 +83,7 @@ export const OtherSettings: React.FC = () => {
return (
<DisabledSetting disabled={disabled}>
<ListGroup title={t("home.settings.other.other_title")} className="">
<ListItem
title={t("home.settings.other.auto_rotate")}
disabled={pluginSettings?.autoRotate?.locked}
>
<ListItem title={t("home.settings.other.auto_rotate")} disabled={pluginSettings?.autoRotate?.locked}>
<Switch
value={settings.autoRotate}
disabled={pluginSettings?.autoRotate?.locked}
@@ -97,17 +93,11 @@ export const OtherSettings: React.FC = () => {
<ListItem
title={t("home.settings.other.video_orientation")}
disabled={
pluginSettings?.defaultVideoOrientation?.locked ||
settings.autoRotate
}
disabled={pluginSettings?.defaultVideoOrientation?.locked || settings.autoRotate}
>
<Dropdown
data={orientations}
disabled={
pluginSettings?.defaultVideoOrientation?.locked ||
settings.autoRotate
}
disabled={pluginSettings?.defaultVideoOrientation?.locked || settings.autoRotate}
keyExtractor={String}
titleExtractor={(item) => ScreenOrientationEnum[item]}
title={
@@ -115,17 +105,11 @@ export const OtherSettings: React.FC = () => {
<Text className="mr-1 text-[#8E8D91]">
{t(ScreenOrientationEnum[settings.defaultVideoOrientation])}
</Text>
<Ionicons
name="chevron-expand-sharp"
size={18}
color="#5A5960"
/>
<Ionicons name="chevron-expand-sharp" size={18} color="#5A5960" />
</TouchableOpacity>
}
label={t("home.settings.other.orientation")}
onSelected={(defaultVideoOrientation) =>
updateSettings({ defaultVideoOrientation })
}
onSelected={(defaultVideoOrientation) => updateSettings({ defaultVideoOrientation })}
/>
</ListItem>
@@ -136,27 +120,49 @@ export const OtherSettings: React.FC = () => {
<Switch
value={settings.safeAreaInControlsEnabled}
disabled={pluginSettings?.safeAreaInControlsEnabled?.locked}
onValueChange={(value) =>
updateSettings({ safeAreaInControlsEnabled: value })
}
onValueChange={(value) => updateSettings({ safeAreaInControlsEnabled: value })}
/>
</ListItem>
{/* {(Platform.OS === "ios" || Platform.isTVOS)&& (
<ListItem
title={t("home.settings.other.video_player")}
disabled={pluginSettings?.defaultPlayer?.locked}
>
<Dropdown
data={Object.values(VideoPlayer).filter(isNumber)}
disabled={pluginSettings?.defaultPlayer?.locked}
keyExtractor={String}
titleExtractor={(item) => t(`home.settings.other.video_players.${VideoPlayer[item]}`)}
title={
<TouchableOpacity className="flex flex-row items-center justify-between py-3 pl-3">
<Text className="mr-1 text-[#8E8D91]">
{t(`home.settings.other.video_players.${VideoPlayer[settings.defaultPlayer]}`)}
</Text>
<Ionicons
name="chevron-expand-sharp"
size={18}
color="#5A5960"
/>
</TouchableOpacity>
}
label={t("home.settings.other.orientation")}
onSelected={(defaultPlayer) =>
updateSettings({ defaultPlayer })
}
/>
</ListItem>
)} */}
<ListItem
title={t("home.settings.other.show_custom_menu_links")}
disabled={pluginSettings?.showCustomMenuLinks?.locked}
onPress={() =>
Linking.openURL(
"https://jellyfin.org/docs/general/clients/web-config/#custom-menu-links"
)
}
onPress={() => Linking.openURL("https://jellyfin.org/docs/general/clients/web-config/#custom-menu-links")}
>
<Switch
value={settings.showCustomMenuLinks}
disabled={pluginSettings?.showCustomMenuLinks?.locked}
onValueChange={(value) =>
updateSettings({ showCustomMenuLinks: value })
}
onValueChange={(value) => updateSettings({ showCustomMenuLinks: value })}
/>
</ListItem>
<ListItem
@@ -164,10 +170,7 @@ export const OtherSettings: React.FC = () => {
title={t("home.settings.other.hide_libraries")}
showArrow
/>
<ListItem
title={t("home.settings.other.default_quality")}
disabled={pluginSettings?.defaultBitrate?.locked}
>
<ListItem title={t("home.settings.other.default_quality")} disabled={pluginSettings?.defaultBitrate?.locked}>
<Dropdown
data={BITRATES}
disabled={pluginSettings?.defaultBitrate?.locked}
@@ -176,14 +179,8 @@ export const OtherSettings: React.FC = () => {
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"
/>
<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.default_quality")}
@@ -197,9 +194,7 @@ export const OtherSettings: React.FC = () => {
<Switch
value={settings.disableHapticFeedback}
disabled={pluginSettings?.disableHapticFeedback?.locked}
onValueChange={(disableHapticFeedback) =>
updateSettings({ disableHapticFeedback })
}
onValueChange={(disableHapticFeedback) => updateSettings({ disableHapticFeedback })}
/>
</ListItem>
</ListGroup>

View File

@@ -1,65 +1,40 @@
import { Text } from "@/components/common/Text";
import { Loader } from "@/components/Loader";
import { useAdjacentItems } from "@/hooks/useAdjacentEpisodes";
import { useCreditSkipper } from "@/hooks/useCreditSkipper";
import { useHaptic } from "@/hooks/useHaptic";
import { useIntroSkipper } from "@/hooks/useIntroSkipper";
import { useTrickplay } from "@/hooks/useTrickplay";
import {
TrackInfo,
VlcPlayerViewRef,
} from "@/modules/vlc-player/src/VlcPlayer.types";
import { apiAtom } from "@/providers/JellyfinProvider";
import { useSettings } from "@/utils/atoms/settings";
import {
getDefaultPlaySettings,
previousIndexes,
} from "@/utils/jellyfin/getDefaultPlaySettings";
import { getItemById } from "@/utils/jellyfin/user-library/getItemById";
import { writeToLog } from "@/utils/log";
import {
formatTimeString,
msToTicks,
secondsToMs,
ticksToMs,
ticksToSeconds,
} from "@/utils/time";
import { Ionicons, MaterialIcons } from "@expo/vector-icons";
import {
BaseItemDto,
MediaSourceInfo,
} from "@jellyfin/sdk/lib/generated-client";
import { Image } from "expo-image";
import { useLocalSearchParams, useRouter } from "expo-router";
import {Text} from "@/components/common/Text";
import {Loader} from "@/components/Loader";
import {useAdjacentItems} from "@/hooks/useAdjacentEpisodes";
import {useCreditSkipper} from "@/hooks/useCreditSkipper";
import {useHaptic} from "@/hooks/useHaptic";
import {useIntroSkipper} from "@/hooks/useIntroSkipper";
import {useTrickplay} from "@/hooks/useTrickplay";
import {TrackInfo, VlcPlayerViewRef,} from "@/modules/VlcPlayer.types";
import {apiAtom} from "@/providers/JellyfinProvider";
import {useSettings, VideoPlayer} from "@/utils/atoms/settings";
import {getDefaultPlaySettings,} from "@/utils/jellyfin/getDefaultPlaySettings";
import {getItemById} from "@/utils/jellyfin/user-library/getItemById";
import {writeToLog} from "@/utils/log";
import {formatTimeString, msToTicks, secondsToMs, ticksToMs, ticksToSeconds,} from "@/utils/time";
import {Ionicons, MaterialIcons} from "@expo/vector-icons";
import {BaseItemDto, MediaSourceInfo,} from "@jellyfin/sdk/lib/generated-client";
import {Image} from "expo-image";
import {useLocalSearchParams, useRouter} from "expo-router";
import * as ScreenOrientation from "@/packages/expo-screen-orientation";
import { useAtom } from "jotai";
import { debounce } from "lodash";
import React, { useCallback, useEffect, useRef, useState } from "react";
import {
Platform,
TouchableOpacity,
useWindowDimensions,
View,
} from "react-native";
import { Slider } from "react-native-awesome-slider";
import {
runOnJS,
SharedValue,
useAnimatedReaction,
useSharedValue,
} from "react-native-reanimated";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { VideoRef } from "react-native-video";
import {useAtom} from "jotai";
import {debounce} from "lodash";
import React, {useCallback, useEffect, useRef, useState} from "react";
import {Platform, TouchableOpacity, useWindowDimensions, View,} from "react-native";
import {Slider} from "react-native-awesome-slider";
import {runOnJS, SharedValue, useAnimatedReaction, useSharedValue,} from "react-native-reanimated";
import {useSafeAreaInsets} from "react-native-safe-area-context";
import {VideoRef} from "react-native-video";
import AudioSlider from "./AudioSlider";
import BrightnessSlider from "./BrightnessSlider";
import { ControlProvider } from "./contexts/ControlContext";
import { VideoProvider } from "./contexts/VideoContext";
import {ControlProvider} from "./contexts/ControlContext";
import {VideoProvider} from "./contexts/VideoContext";
import DropdownView from "./dropdown/DropdownView";
import { EpisodeList } from "./EpisodeList";
import {EpisodeList} from "./EpisodeList";
import NextEpisodeCountDownButton from "./NextEpisodeCountDownButton";
import SkipButton from "./SkipButton";
import { useControlsTimeout } from "./useControlsTimeout";
import { VideoTouchOverlay } from "./VideoTouchOverlay";
import {useControlsTimeout} from "./useControlsTimeout";
import {VideoTouchOverlay} from "./VideoTouchOverlay";
interface Props {
item: BaseItemDto;
@@ -494,7 +469,7 @@ export const Controls: React.FC<Props> = ({
)}
<View className="flex flex-row items-center space-x-2 ">
{!Platform.isTV && (
{!Platform.isTV && settings.defaultPlayer == VideoPlayer.VLC_4 && (
<TouchableOpacity
onPress={startPictureInPicture}
className="aspect-square flex flex-col rounded-xl items-center justify-center p-2"

View File

@@ -1,4 +1,3 @@
import { TrackInfo } from "@/modules/vlc-player";
import {
BaseItemDto,
MediaSourceInfo,

View File

@@ -1,4 +1,4 @@
import { TrackInfo } from "@/modules/vlc-player";
import { TrackInfo } from "@/modules/VlcPlayer.types";
import React, { createContext, useContext, useState, ReactNode, useEffect, useMemo } from "react";
import { useControlContext } from "./ControlContext";
import { Track } from "../types";

View File

@@ -1,7 +1,7 @@
import {
TrackInfo,
VlcPlayerViewRef,
} from "@/modules/vlc-player/src/VlcPlayer.types";
} from "@/modules/VlcPlayer.types";
import React, { useEffect, useState } from "react";
import { TouchableOpacity, View, ViewProps } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";