2.3.0 • Published 3 years ago

@twincitiespublictelevision/pbs-partner v2.3.0

Weekly downloads
17
License
Apache-2.0
Repository
github
Last release
3 years ago

pbs-partner

CircleCI Documentation

pbs-partner is a library for connecting to a PBS Partner Player instance, sending commands, and listening for events.


Overview

pbs-partner exposes a single main function PBSPartner that can be instantiated and connected to a PBS Partner Player iframe. A single instance maps to a single player.

Communication with the iframe occurs over via the postMessage API. Note that listening for messages is shared and the library attempts to match up events to the iframe instance that spawned the message. If the src of the iframe changes, it is recommended to close the old object and instantiate a new one. Currently, binding a single iframe to multiple PBSPartner instances is not supported.

Usage

let player = new PBSPartner();
player.setPlayer(document.getElementById('video-player'));

player.analytics.setTrackingFunction(ga);
player.analytics.addMediaTracking(
  'Video Player', // Event Category
  'Label for Video', // Event Label
  'metric1',
  {
    start: 'MediaStart', // Event Action - Start
    stop: 'MediaStop' // Event Action - Stop
  }
);

Install

npm install @twincitiespublictelevision/pbs-partner

Extending PBSPlayer

The library is split into three main parts: a Message function for sending and receiving messages, a MediaEvents function for translating lower level events into higher level MediaStart and MediaStop events, and finally Player function for tracking durations and adding plugins.

A plugin is a function that accepts a PBSPlayer and provides additional functionality. A plugin can be added via the PBSPlayer.

PBSPlayer.addPlugin('analytics', GoogleAnalytics);

PBSPlayer comes with a GoogleAnalytics plugin for tracking MediaStart and MediaStop events by default.

2.3.0

3 years ago

2.2.0

4 years ago

2.1.0-alpha

4 years ago

2.0.0-alpha

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago