Skip to content

Commit

Permalink
Added check for window
Browse files Browse the repository at this point in the history
  • Loading branch information
SujithThirumalaisamy committed Nov 28, 2024
1 parent 6dd4e87 commit a51e9ef
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/VideoPlayer2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ export const VideoPlayer: FunctionComponent<VideoPlayerProps> = ({
const [player, setPlayer] = useState<any>(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 {
Expand Down Expand Up @@ -478,7 +482,7 @@ export const VideoPlayer: FunctionComponent<VideoPlayerProps> = ({

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

if (appxVideoId)
if (appxVideoId && typeof window !== 'undefined' && courseId)
return <AppxVideoPlayer courseId={courseId} videoId={appxVideoId} />;

return (
Expand Down

0 comments on commit a51e9ef

Please sign in to comment.