diff --git a/frontend/src/components/GoogleCast.tsx b/frontend/src/components/GoogleCast.tsx index d862d343..e7eb36cd 100644 --- a/frontend/src/components/GoogleCast.tsx +++ b/frontend/src/components/GoogleCast.tsx @@ -138,6 +138,13 @@ const GoogleCast = ({ video, setRefresh, onWatchStateChanged }: GoogleCastProps) // eslint-disable-next-line react-hooks/exhaustive-deps }, [setRefresh, video]); + // @ts-expect-error __onGCastApiAvailable is the google cast window hook ( source: https://developers.google.com/cast/docs/web_sender/integrate ) + window['__onGCastApiAvailable'] ??= function (isAvailable: boolean) { + if (isAvailable) { + setup(); + } + }; + const startPlayback = useCallback(() => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const chrome = (globalThis as any).chrome; @@ -195,15 +202,6 @@ const GoogleCast = ({ video, setRefresh, onWatchStateChanged }: GoogleCastProps) // eslint-disable-next-line react-hooks/exhaustive-deps }, [video?.media_url, video?.subtitles, video?.title, video?.vid_thumb_url]); - useEffect(() => { - // @ts-expect-error __onGCastApiAvailable is the google cast window hook ( source: https://developers.google.com/cast/docs/web_sender/integrate ) - window['__onGCastApiAvailable'] = function (isAvailable: boolean) { - if (isAvailable) { - setup(); - } - }; - }, [setup]); - useEffect(() => { console.log('isConnected', isConnected); if (isConnected) {