Code Monkey home page Code Monkey logo

nexplayer_html5_mux's Introduction

NexPlayer demo home

Integration of NexPlayer HTML5 with Mux Data

NexPlayer™ HTML5 is a multi-screen streaming player that enables HLS and DASH live streaming across all browsers and platforms with the highest video quality. NexPlayer™ HTML5 supports, an advanced feature set that includes DRM, Closed Captioning, Time Shifting and 360 video playback among many others.

This repository contains the sample demo code of NexPlayer™ HTML5 with the integration of Mux Data.

Using with the player

To start, you need to have an ENV_KEY from the Mux environments dashboard. ENV_KEY is a client-side key used for Mux Data monitoring. These are not to be confused with API tokens which are created in the admin settings dashboard and meant to access the Mux API from a trusted server.

In order to use it, you need to import these files into the HTML and set the muxPlayerInitTime.

  <head>
    <script src="https://src.litix.io/core/4/mux.js"></script>
    <script src="Nexplayer SDK latest release"></script>
    <script src="https://nexplayer.nexplayersdk.com/Mux/NexMuxHandShake.js"></script>
    <script>window.muxPlayerInitTime = Date.now()</script>
  </head>

You can find NexMuxHandShake.js in the following repository.

Nexplayer SDK releases

First you should create your muxConfiguration variable with the following structure:

var muxConfiguration = {
  debug: true,
  disableCookies: true,
  respectDoNotTrack: true,
  automaticErrorTracking: true,
  data: {
    env_key: 'ENV_KEY', // required

    // Site Metadata
    viewer_user_id: '', // ex: '12345'
    experiment_name: '', // ex: 'player_test_A'
    sub_property_id: '', // ex: 'cus-1'

    // Player Metadata
    player_name: 'NexPlayer', // ex: 'My Main Player'
    player_version:  '', // ex: '1.0.0'
    player_init_time: window.muxPlayerInitTime, // ex: 1451606400000

    // Video Metadata
    video_id: '', // ex: 'abcd123'
    video_title: '', // ex: 'My Great Video'
    video_series: '', // ex: 'Weekly Great Videos'
    video_duration: '', // in milliseconds, ex: 120000
    video_stream_type: '', // 'live' or 'on-demand'
    video_cdn: '' // ex: 'Fastly', 'Akamai'
  },
};

Properties:

Param Type Description
debug boolean Enable or disable debug mode
disableCookies boolean Disable or enable the cookie that Mux uses to track playback across subsequent page views if desired.
respectDoNotTrack boolean By default, mux does not respect Do Not Track when set within browsers. This can be enabled or disabled by this property.
automaticErrorTracking boolean Enable or disable automatic error tracking completely.
data Object Site, player and video metadata.

NexMuxHandshake should be created in the callBackWithPlayers after the event “loadeddata” is fired. This object links Nexplayer and Mux events and functions.

  var nexMux = null;

  var callBackWithPlayers = function (nexplayerInstance, videoElement) {

    player = nexplayerInstance;
    videoElem = videoElement;

    videoElem.addEventListener("loadeddata", function() {

      nexMux = new NexMuxHandShake();
      // To use ad metrics, set useAdMetrics to true, it is set to false by default.
      nexMux.useAdMetrics = true;
      nexMux.initMuxData(player, videoElem.id, muxConfiguration);
    });
  }

Changing the video

If your application plays multiple videos back-to-back in the same video player, you should use the following function and pass a data object with the same structure as the muxConfiguration.data object.

  nexMux.videoChange(videoElem.id, data);

In some cases, you may have the program change within a stream, and you may want to track each program as a view on its own. To do so you should use the following function and pass a data object with the same structure as the muxConfiguration.data object.

  nexMux.programChange(videoElem.id, data);

Request demo

Product page NexPlayer™ HTML5

Contact

[email protected]

License

NexPlayer™ HTML5 Product License

nexplayer_html5_mux's People

Contributors

bryantaipe avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.