mirror of
https://github.com/streamyfin/streamyfin.git
synced 2025-08-20 18:37:18 +02:00
fix: show cast icon when casting
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user