Lumen help

Integrating Mesh Delivery with Hls.js

Introduction

Step 1: Install Hls.js and Mesh Delivery builds

From our CDN

                <!-- Hls.js build -->
<script src="//cdn.jsdelivr.net/npm/hls.js@0.12.2/dist/hls.min.js"></script>

<!-- Mesh Delivery wrapper -->
<script src="//cdn.streamroot.io/hlsjs-dna-wrapper/1/stable/hlsjs-dna-wrapper.js?srKey=YOUR_STREAMROOT_KEY"></script>

            

To get the highest flexibility of deployment, we recommend setting the StreamrootKey in the Query Parameter "srKey".

 

Parameter name

Mandatory

Description

YOUR_STREAMROOT_KEY

Yes      

The unique Streamroot key that we have assigned to you; make sure it is identical to the one provided in the Account section of your dashboard.

Using npm

Install runtime and dev dependencies:

                npm install @streamroot/hlsjs-dna-wrapper
            

In your application, import/require the package you want to use, like this example:

                import HlsjsDnaWrapper from '@streamroot/hlsjs-dna-wrapper';
            

Step 2: Set up Hls.js and Mesh Delivery

In the HTML <body> or with npm

                <video id="demoplayer"></video>
<script>
    var hlsjsConfig = {};
    var dnaConfig = {};
    var hls = new Hls(hlsjsConfig);
    var wrapper = new HlsjsDnaWrapper(hls, 'YOUR_STREAMROOT_KEY', dnaConfig);
    var video = document.getElementById('demoplayer');
    hls.loadSource('YOUR_PLAYLIST_URL');
    hls.attachMedia(video);
    hls.on(Hls.Events.MANIFEST_PARSED,function() {
        video.play();
    });
</script>

            
Vizualization graph for Mesh Delivery

Recommended Options

                var hlsjsConfig = {
   "maxBufferSize": 0,
   "maxBufferLength": 30,
   "liveSyncDuration": 30,
   "liveMaxLatencyDuration": Infinity
}

            
                var hlsjsConfig = {
   "maxBufferSize": 0,
   "maxBufferLength": 30
}