Socket
Socket
Sign inDemoInstall

@api.video/hlsjs-player-analytics

Package Overview
Dependencies
4
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @api.video/hlsjs-player-analytics

api.video player analytics plugin for hls.js based players


Version published
Weekly downloads
44
increased by10%
Maintainers
3
Created
Weekly downloads
 

Readme

Source

api.video player analytics module for hls.js based players

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

Module usage

Setup

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

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

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 VideoElementApiVideoAnalytics(hls, {
    sequence: {
        start: 10,
        end: 50
    },
    userMetadata: {
        gender: "male"
    }
});

Full example

Include the module in your HTML file like so:

<html>
    <head>
        <script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
        <script src="https://unpkg.com/@api.video/hlsjs-player-analytics"></script>
    </head>
    
    <body>
        <video id="video" controls width=640 height=480></video>
    <script>
        var video = document.getElementById('video');
        
        var videoSrc = 'https://cdn.api.video/vod/vi5oDagRVJBSKHxSiPux5rYD/hls/manifest.m3u8';
        if (Hls.isSupported()) {
            var hls = new Hls();
            new VideoElementApiVideoAnalytics(hls);
            hls.loadSource(videoSrc);
            hls.attachMedia(video);
        }
    </script>
    </body>
</html>

Keywords

FAQs

Last updated on 30 Jun 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc