Plugins

PRESTOplay for web ships with a solid set of built-in plugins that extend the player or integrate it with third-party services such as analytics and advertising. When you need to go further, the plugin system also lets you extend and customize the SDK yourself.

Built-in plugins

Each plugin ships as a separate module and must be imported before creating the player to register it.

Plugin

Use

Adobe Analytics

Reports playback metrics to Adobe Analytics via the s.Media API.

AirPlay

Casts to AirPlay receivers. See AirPlay.

Broadpeak

Broadpeak server-side ad insertion and analytics. See Analytics.

Conviva

Reports playback metrics to Conviva Experience Insights. See Analytics.

FreeWheel

FreeWheel ad insertion. See Advertising.

HLS SMPTE-TT

Processes SMPTE-TT image cues in HLS streams. See Subtitles.

IMA

Google Interactive Media Ads (IMA) SDK integration. See Advertising.

Mux Data

Reports playback metrics to Mux Data. See Analytics.

MediaTailor

AWS Elemental MediaTailor server-side ad insertion.

NPAW / Youbora

Reports playback metrics to NPAW (Youbora). See Analytics.

Playlist

Sequential playback of multiple media items. See Playlist.

SIMID

Secure Interactive Media Interface Definition (SIMID) support for interactive ad creatives.

Thumbnails

Loads and parses thumbnail previews. See Thumbnails.

Vimond

Vimond integration. Deprecated — will be removed in a future major version.

VR

Adds 360-degree video playback support.

Yospace

Yospace server-side ad insertion. See Advertising.

Writing a custom plugin

PRESTOplay plugins are class-based components that implement the PlayerPlugin interface. The interface defines a set of callbacks and hooks that the player calls at different points during its lifecycle.

The player calls these callbacks on each plugin instance:

Callback

Called

onPlayerCreated(player)

When the Player instance is created. Set up anything that lives as long as the player, such as UI.

onContentWillLoad(player, source)

Before content loads. Register event listeners here. Return a URL, or a promise that resolves with one, to replace the stream URL. If a promise is returned, loading waits for it.

onContentLoaded(player)

After content loads. Content information such as Player.isLive and Player.getDuration is available from this point.

onPlayerWillRelease(player)

Before the current content is released, including before each new Player.open call. Remove the listeners registered in onContentWillLoad.

onPlayerWillDestroy(player)

Before the player is destroyed. Clean up everything else.

id()

Returns the plugin ID. The plugin instance is then available through Player.getPlugin.

The custom plugin sample implements every callback in a plugin that renders a stats overlay on top of the video and shows when each callback runs.

Registering a plugin

Register the plugin with the SDK before using it. The SDK exposes a plugin factory PlayerPluginFactory interface that you implement and provide.

A generic plugin factory that creates instances of a MyPlugin class looks like this:

/**
 * @implements {clpp.PlayerPluginFactory}
 */
class MyPluginFactory {
  /**
   * @override
   */
  create (playerConfig) {
    return new MyPlugin();
  }
};

Register the factory with the player using Player.registerPlugin:

// *Before* the player instance is created
clpp.Player.registerPlugin(new MyPluginFactory());

// ...

// Now the plugin will be used with each new instance of the player.
const player = new clpp.Player(...);
Next topic: Advertising
Previous topic: Smart TV