Hls.js analytics plugin

Analytics module for hls.js based video players, to call the api.video analytics collector.

badge   badge   badge

npm ts

api.video hls.js analytics module

api.video is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.

Table of contents

Project description

hls.js module to call the api.video analytics collector.

Getting started


Include https://unpkg.com/@api.video/hlsjs-player-analytics in your web page.

<script src="https://unpkg.com/@api.video/hlsjs-player-analytics"></script>

Code sample

Include the module in your HTML file like so:

        <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
        <script src="https://unpkg.com/@api.video/hlsjs-player-analytics"></script>
        <video id="video" controls width=640 height=480></video>
        var video = document.getElementById('video');
        var videoSrc = 'https://cdn.api.video/vod/vi5oDagRVJBSKHxSiPux5rYD/hls/manifest.m3u8';
        if (Hls.isSupported()) {
            var hls = new Hls();
            new HlsJsApiVideoAnalytics(hls);


Module instanciation

Then, before having instanciated Hls, instanciate a HlsJsApiVideoAnalytics object.

The HlsJsApiVideoAnalytics constructor take the following parameters:

Parameter nameMandatoryTypeDescription
hlsyesHls instancethe instance of Hls
optionsnoHlsJsApiVideoAnalyticsOptions (see below)optional options

Available options (HlsJsApiVideoAnalyticsOptions):

Option nameMandatoryTypeDescription
userMetadatano{ [name: string]: string }[]object containing metadata (see Full example below)
sequenceno{start: number; end?: number;} if only a sequence of the video is going to be played

Instanciation example

var hls = new Hls();

new HlsJsApiVideoAnalytics(hls, {
    sequence: {
        start: 10,
        end: 50
    userMetadata: {
        gender: "male"