p2p-media-loader icon indicating copy to clipboard operation
p2p-media-loader copied to clipboard

initVideoJsHlsJsPlugin() - videojs is not defined error

Open RyanSacks opened this issue 2 years ago • 0 comments

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.

RyanSacks avatar Oct 02 '21 15:10 RyanSacks