From a51e9efbefc3e6a98df805c279cd94b37930ffea Mon Sep 17 00:00:00 2001 From: SujithThirumalaisamy Date: Thu, 28 Nov 2024 22:07:23 +0530 Subject: [PATCH] Added check for window --- src/components/VideoPlayer2.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/VideoPlayer2.tsx b/src/components/VideoPlayer2.tsx index 20521be9..7257173a 100644 --- a/src/components/VideoPlayer2.tsx +++ b/src/components/VideoPlayer2.tsx @@ -46,8 +46,12 @@ export const VideoPlayer: FunctionComponent = ({ const [player, setPlayer] = useState(null); const searchParams = useSearchParams(); const vidUrl = options.sources[0].src; - const href = window.location.href; - const courseId = href.split('/')[4]; + let href: string | null = null; + let courseId: string | null = null; + if (typeof window !== 'undefined') { + href = window.location.href; + courseId = href.split('/')[4]; + } const togglePictureInPicture = async () => { try { @@ -478,7 +482,7 @@ export const VideoPlayer: FunctionComponent = ({ if (isYoutubeUrl(vidUrl)) return ; - if (appxVideoId) + if (appxVideoId && typeof window !== 'undefined' && courseId) return ; return (