fix: show cast icon when casting

This commit is contained in:
Fredrik Burmester
2024-08-06 09:10:12 +02:00
parent 30db87bed1
commit 0f9d53ed27

View File

@@ -6,7 +6,7 @@ import {
reportPlaybackStopped, reportPlaybackStopped,
} from "@/utils/jellyfin"; } from "@/utils/jellyfin";
import { runtimeTicksToMinutes } from "@/utils/time"; import { runtimeTicksToMinutes } from "@/utils/time";
import { Ionicons } from "@expo/vector-icons"; import { Feather, Ionicons } from "@expo/vector-icons";
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api"; import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api";
import { useQuery, useQueryClient } from "@tanstack/react-query"; import { useQuery, useQueryClient } from "@tanstack/react-query";
import { useAtom } from "jotai"; import { useAtom } from "jotai";
@@ -214,6 +214,10 @@ export const VideoPlayer: React.FC<VideoPlayerProps> = ({ itemId }) => {
} }
}, []); }, []);
const chromecastReady = useMemo(() => {
return castDevice?.deviceId && item;
}, [castDevice, item]);
return ( return (
<View> <View>
{enableVideo === true && {enableVideo === true &&
@@ -313,13 +317,19 @@ export const VideoPlayer: React.FC<VideoPlayerProps> = ({ itemId }) => {
<Button <Button
disabled={!enableVideo} disabled={!enableVideo}
onPress={() => { onPress={() => {
if (castDevice?.deviceId && item) { if (chromecastReady) {
cast(); cast();
} else if (videoRef.current) { } else if (videoRef.current) {
videoRef.current.presentFullscreenPlayer(); videoRef.current.presentFullscreenPlayer();
} }
}} }}
iconRight={<Ionicons name="play-circle" size={24} color="white" />} iconRight={
chromecastReady ? (
<Feather name="cast" size={20} color="white" />
) : (
<Ionicons name="play-circle" size={24} color="white" />
)
}
> >
{runtimeTicksToMinutes(item?.RunTimeTicks)} {runtimeTicksToMinutes(item?.RunTimeTicks)}
</Button> </Button>