GithubHelp home page GithubHelp logo

twincitiespublictelevision / pbs-partner Goto Github PK

View Code? Open in Web Editor NEW
1.0 7.0 0.0 2.63 MB

A library for interacting with an embedded PBS partner player.

License: Apache License 2.0

JavaScript 98.85% HTML 1.15%

pbs-partner's Introduction

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.

pbs-partner's People

Contributors

augustuswm avatar dependabot[bot] avatar tptwebmaster avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pbs-partner's Issues

Pause event fired on video complete

With 2.0.0-alpha, I'm seeing a pause event fire before the (first) complete event with the VideoJS player.

When a video is played to end with VideoJS, I see:

  1. pause
  2. complete
  3. MediaStop
  4. complete

When a video is played to end with JWPlayer, I see:

  1. complete
  2. MediaStop
  3. complete

Potentially related, I have never noticed the two complete events before. I'm not sure if that is a new or existing issue.

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.