Skip to content

Commit 2b73e53

Browse files
authored
Merge pull request #1593 from SujithThirumalaisamy/main
Fixed the check for window
2 parents 6dd4e87 + a51e9ef commit 2b73e53

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/components/VideoPlayer2.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ export const VideoPlayer: FunctionComponent<VideoPlayerProps> = ({
4646
const [player, setPlayer] = useState<any>(null);
4747
const searchParams = useSearchParams();
4848
const vidUrl = options.sources[0].src;
49-
const href = window.location.href;
50-
const courseId = href.split('/')[4];
49+
let href: string | null = null;
50+
let courseId: string | null = null;
51+
if (typeof window !== 'undefined') {
52+
href = window.location.href;
53+
courseId = href.split('/')[4];
54+
}
5155

5256
const togglePictureInPicture = async () => {
5357
try {
@@ -478,7 +482,7 @@ export const VideoPlayer: FunctionComponent<VideoPlayerProps> = ({
478482

479483
if (isYoutubeUrl(vidUrl)) return <YoutubeRenderer url={vidUrl} />;
480484

481-
if (appxVideoId)
485+
if (appxVideoId && typeof window !== 'undefined' && courseId)
482486
return <AppxVideoPlayer courseId={courseId} videoId={appxVideoId} />;
483487

484488
return (

0 commit comments

Comments
 (0)