Skip to content

Instantly share code, notes, and snippets.

@michael-riha
Created August 9, 2019 06:44
Show Gist options
  • Select an option

  • Save michael-riha/2a58abc71222b7642af98ed5fea39fe0 to your computer and use it in GitHub Desktop.

Select an option

Save michael-riha/2a58abc71222b7642af98ed5fea39fe0 to your computer and use it in GitHub Desktop.

Revisions

  1. michael-riha created this gist Aug 9, 2019.
    26 changes: 26 additions & 0 deletions analytics-videoJS-first-load.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    const analyticsConfig = {
    key: '<ANALYTICS-KEY>',
    videoId: 'video-empty',
    userId: 'xxx_01',
    cdnProvider: 'some_cdn',
    customData1: 'sport',
    title: 'video title set without a source, yet',
    debug: true
    };

    const player = videojs('my-player');
    const analytics = new bitmovin.analytics.adapters.VideojsAdapter(analyticsConfig, player);
    player.ready(function(event) {
    console.log("player is ready");
    let sourceConfig= {
    title: 'the first video title set with first source',
    videoId: 'video-1'
    }
    console.log("before change-> ", analytics.analytics.sample.videoId, analytics.analytics.sample);
    analytics.sourceChange(sourceConfig);
    console.log("after change-> ", analytics.analytics.sample.videoId, analytics.analytics.sample);
    player.src({
    src: 'https://bitmovin-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8',
    type: 'application/x-mpegURL',
    });
    });