Mux Data

Code samples

  • Mux Data: the complete setup, including muxOptionsOverride and a custom event helper.

To use the Mux Data plugin with PRESTOplay for Web Apps, include the Mux Data library in your project via NPM.

Note

The minimum Mux Data SDK version recommended by this integration is 4.30.0.

npm i mux-embed@4.30.0

Import the PRESTOplay Mux Data plugin:

import "@castlabs/prestoplay/cl.muxdata";

Provide the Mux Data configuration as part of the player configuration:

const playerConfig = {
  ...
  muxdata: {
    envKey: '<your_env_key>'
  }
};

If you use a module loader to import the Mux SDK into your project, pass the Mux SDK as part of the config:

import mux from 'mux-embed';
...

const playerConfig = {
  ...,
  muxdata: {
    muxLib: mux, // The Mux Data core SDK.
    envKey: '<your_env_key>'
  }
}

You can also override or extend the configuration passed to the Mux library by setting muxOptionsOverride to an object containing valid Mux SDK options.

const playerConfig = {
  ...,
  muxdata: {
    muxLib: mux, // The Mux Data core SDK.
    envKey: '<your_env_key>',
    muxOptionsOverride: { // Valid Mux Data SDK options.
      debug: false,
      data: {
        player_name: 'MyPlatform-Web-Player',
        player_version: '2.3.7',
        viewer_user_id: 'new_id',
        page_type: 'watchpage',
        sub_property_id: 'some-id',
        // ...
      },
      automaticErrorTracking: false,
      respectDoNotTrack: false,
    }
  }
}

Custom events

To report a custom event that isn’t covered by the plugin, access the underlying Mux Data SDK emit() method:

const mux = player.getPlugin('mux')

// Emit a heartbeat event with a custom value according to the docs.
mux.emit('hb', {
  custom_value: 'custom_value'
})

All mandatory Mux playback events are covered by the plugin and shouldn’t be emitted manually.

Next topic: Migration guide
Previous topic: Broadpeak