Novage / p2p-media-loader

An open-source engine for P2P streaming of live and on demand video directly in a web browser HTML page
https://novage.com.ua/p2p-media-loader/demo.html
Apache License 2.0
1.43k stars 314 forks source link

How to integrate with playerjs.com #222

Closed marcoscv1981 closed 3 years ago

marcoscv1981 commented 3 years ago

it plays normal on perfect playerjs but doesn't share p2p through this player

function PlayerjsEvents(event,id,data) {
    if (event === "new") {
        window.player.p2pEngine = new p2pml.hlsjs.Engine();

        // store global config
        const config = Hls.DefaultConfig;
        window.player.originalConfig = config;

        // set hls.js config for this instance using global configuration objects
        Hls.DefaultConfig = {
            ...config,
            liveSyncDurationCount: 7,
            loader: window.player.p2pEngine.createLoaderClass()
        };
    } else if (event === "play") {
        const hls = window.player.api("hls");

        if (!hls.p2pInitialized) {
            // initialize hls.js instance
            p2pml.hlsjs.initHlsJsPlayer(hls);
            hls.p2pInitialized = true;
            Hls.DefaultConfig = window.player.originalConfig; // restore global config
        }
    }
}

window.player = new Playerjs({id: "player", file: "https://akamai-axtest.akamaized.net/routes/lapd-v1-acceptance/www_c4/Manifest.m3u8"});