Skip to content

Commit

Permalink
Merge pull request #1593 from SujithThirumalaisamy/main
Browse files Browse the repository at this point in the history
Fixed the check for window
  • Loading branch information
hkirat authored Nov 28, 2024
2 parents 6dd4e87 + a51e9ef commit 2b73e53
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 2b73e53

Please sign in to comment.