Broadpeak

Broadpeak SmartLib integrates with PRESTOplay for Web Apps via NPM and script tag. See the Broadpeak project setup documentation for Broadpeak-specific setup details.

Code samples

Install with NPM

The minimum SmartLib version supported by this integration is 5.4.4-808048b.

Add the Broadpeak NPM registry:

npm config set @broadpeak:registry https://delivery-platform.broadpeak.tv/js/

Install SmartLib:

npm install @broadpeak/smartlib@5.4.4-808048b
npm install @broadpeak/smartlib-analytics@5.4.4-808048b

For other installation methods, see the Broadpeak project setup documentation. If your project needs a pre-transpiled bundle, use @broadpeak/smartlib-all-compatibility instead.

Import the SmartLib files and the PRESTOplay Broadpeak plugin:

import { SmartLib } from '@broadpeak/smartlib';
import '@broadpeak/smartlib-analytics';

import { clpp } from '@castlabs/prestoplay';
import '@castlabs/prestoplay/cl.broadpeak';

window.SmartLib = SmartLib; // Required by the PRESTOplay Broadpeak plugin.

Configuration

Add the Broadpeak configuration to your player. Set broadpeakDomainNames to a comma-separated list of the CDN domains that serve content through Broadpeak:

const playerConfig = {
  ...
  broadpeak: {
    broadpeakDomainNames: 'cdn.broadpeak.example,cdn2.broadpeak.example',
  },
};

Two special values are also accepted: '*' if every URL the player loads is served through Broadpeak, or '' if none are.

See BroadpeakConfiguration for all available configuration options.

Session options

Pass session options via broadpeak.sessionOptions, using StreamingSessionOptions constants as keys:

const playerConfig = {
  ...
  broadpeak: {
    broadpeakDomainNames: '',
    sessionOptions: {
      [StreamingSessionOptions.GDPR_PREFERENCE]:
        StreamingSessionOptions.GDPR_CLEAR,
      [StreamingSessionOptions.SESSION_KEEPALIVE_FREQUENCY]: 5000,
      [StreamingSessionOptions.SESSION_PRECACHE]: false, // Defaults to false when omitted.
    },
  },
};

See the Broadpeak documentation on session options for more information.

Broadpeak SSAI ads

The Broadpeak plugin integrates server-side ad insertion (SSAI) tracking into PRESTOplay for Web Apps, automatically handling ad tracking and emitting client-side events.

To enable this feature, extend your Broadpeak analytics installation with the Broadpeak ads module:

npm install @broadpeak/smartlib-ad@5.4.4-808048b

Then enable ad tracking in the Broadpeak config with adTracking: true and, optionally, pass adParameters to enable ad personalization. See the Broadpeak documentation for details about supported ad parameters.

player.open({
  source: {
    url: 'https://stream.broadpeak.io/...',
    type: clpp.Type.DASH,
  },
  broadpeak: {
    broadpeakDomainNames: '...',
    analyticsAddress: '...',
    adTracking: true,
    adParameters: {
      deviceType: 'desktop',
      userId: 'user123',
      contentGenre: 'sports',
      // ... any additional targeting parameters
    },
  },
});

For ad click-through to work properly, the default HTML5 video controls (<video controls>) must be hidden. This is typically not an issue, since most players use custom UI controls.

Broadpeak ad events

Ad metadata is surfaced through the standard ad events described in Advertising.

For SSAI ads in live streams, duration and ad count may not be known, especially for ads appearing on the live edge. In that case, IAd returns -1. Handle this case gracefully when rendering UI.

ad.getDuration() // -1 (unknown)
ad.getSequenceLength() // -1 (unknown)
Next topic: Mux Data
Previous topic: NPAW