videojs / videojs-youtube

YouTube playback technology for Video.js
1.12k stars 548 forks source link

video.js and video-youtube.js throwing "Cannot read properties of undefined (reading 'videojs')" when loading page #596

Open Velocedge opened 2 years ago

Velocedge commented 2 years ago

I'm trying to play a Youtube video using videojs and videojs-youtube. I posted this in Stackoverflow first then I saw this page.

I've installed the latest versions with npm (videojs 7.18.1, videoojs-youtube 2.6.1). I'm loading in this order:

<script type="text/javascript" src="/node_modules/video.js/dist/video.js"></script>
<script type="module" src="/node_modules/videojs-youtube/dist/Youtube.js"></script>

When the page loads, I get the error: "Cannot read properties of undefined (reading 'videojs')" when it hits line 32:

root.Youtube = factory(root.videojs);

Upon entry to this function, "root" is undefined.

I'm not sure how to fix this or what other information you need to explain why I'm getting the error. This code is in the frame of a frameset if that makes a difference. I've changed the JavaScript example into an .asp frameset and used the same type of include files and it works fine. Could I have variable or function names that conflict... something like that?