initVideoJsHlsJsPlugin() - videojs is not defined error
RyanSacks opened this issue · comments
Ryan Sacks commented
Hi, I'm trying to create a player for the initVideoJsHlsJsPlugin(), using the following sample code from npm page:
var engine = new p2pml.hlsjs.Engine();
p2pml.hlsjs.initVideoJsHlsJsPlugin();
var player = videojs("video", {
html5: {
hlsjsConfig: {
liveSyncDurationCount: 7,
loader: engine.createLoaderClass()
}
}
});
player.src({
src: "https://example.com/path/to/your/playlist.m3u8",
type: "application/x-mpegURL"
});
But I get the following error:
Uncaught (in promise) ReferenceError: videojs is not defined
at Object.s.initVideoJsHlsJsPlugin (p2p-media-loader-hlsjs.min.js:1)
---------------------- !! UPDATE !! ----------------------
This error when away when I moved the video.min.js script tag from the bottom right before the closing body tag, to the top of the page inside the head tag.
Now I get a new error:
video.min.js:12 VIDEOJS: ERROR: TypeError: Cannot read properties of undefined (reading 'length')
at e.t.shouldSwitchToMedia_ (video.min.js:27)
I'm using Chrome Version 94.0.4606.61 on a Mac book pro Mojave version 10.14.6.