diff --git a/app.json b/app.json index 52c2504a..f38e93a5 100644 --- a/app.json +++ b/app.json @@ -37,7 +37,7 @@ "android.permission.FOREGROUND_SERVICE", "android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" ], - "versionCode": 6 + "versionCode": 7 }, "web": { "bundler": "metro", diff --git a/app/(auth)/items/[id]/page.tsx b/app/(auth)/items/[id]/page.tsx index d2118d5e..7b8bb901 100644 --- a/app/(auth)/items/[id]/page.tsx +++ b/app/(auth)/items/[id]/page.tsx @@ -26,7 +26,7 @@ import { PlayButton } from "@/components/PlayButton"; import { Bitrate, BitrateSelector } from "@/components/BitrateSelector"; import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api"; import { getStreamUrl } from "@/utils/jellyfin/media/getStreamUrl"; -import { useCastDevice } from "react-native-google-cast"; +import { useCastDevice, useRemoteMediaClient } from "react-native-google-cast"; import { chromecastProfile } from "@/utils/profiles/chromecast"; import ios12 from "@/utils/profiles/ios12"; import { currentlyPlayingItemAtom } from "@/components/CurrentlyPlayingBar"; @@ -41,6 +41,8 @@ const page: React.FC = () => { const castDevice = useCastDevice(); + const chromecastReady = useMemo(() => !!castDevice?.deviceId, [castDevice]); + const [maxBitrate, setMaxBitrate] = useState({ key: "Max", value: undefined, @@ -113,13 +115,30 @@ const page: React.FC = () => { }); const [cp, setCp] = useAtom(currentlyPlayingItemAtom); + const client = useRemoteMediaClient(); const onPressPlay = useCallback(() => { if (!playbackUrl || !item) return; - setCp({ - item, - playbackUrl, - }); + + if (chromecastReady && client) { + client.loadMedia({ + mediaInfo: { + contentUrl: playbackUrl, + contentType: "video/mp4", + metadata: { + type: item.Type === "Episode" ? "tvShow" : "movie", + title: item.Name || "", + subtitle: item.Overview || "", + }, + }, + startTime: 0, + }); + } else { + setCp({ + item, + playbackUrl, + }); + } }, [playbackUrl, item]); if (l1)