Custom Player Integration SDK
Manually integrate your video player with our custom player SDK.
Last updated
Manually integrate your video player with our custom player SDK.
Last updated
If your video player is not listed among our Supported OVPs, you may use our Video SDK to create a custom integration. The primary task is to define a JavaScript Class - referred to as a strategy - which interfaces with your native video API to return values measured by the Chartbeat Publishing Video platform. These include values such as video state (playing, stopped, completed, etc.), video duration, video thumbnail, playhead position, and so on.
simplified_strategy.js is a template for creating a strategy class with no external dependencies. The comments in the code explains what each of the methods in the strategy class need to do.
strategy_interface.js is a Google Closure implementation of the strategy interface. If you’re using Google Closure, it defines all the required methods for you. Using Google Closure is not a requirement if you use the simplified_strategy.js
as a basis for your object.
strategy_html_player.js is an example file showing how Chartbeat implemented the video strategy constructor for HTML5 video players.
On each page with embedded video, you will need to push your video strategy constructor—as customized in strategy_interface.js
— so that Chartbeat's pinger can use it to watch for video events. For the constructor, “CUSTOM_STRATEGY_CONSTRUCTOR”, you would push the constructor like this:
Note: Make sure to push your video strategy constructor to _cbv_strategies
synchronously, before Chartbeat's pinger (chartbeat_video.js
) loads.
Whenever a new video player loads on the page, push the video object to _cbv. This should come after you’ve pushed your video strategy constructor, as in Step 1. For each individual video player, push the video object as below:
Make sure to do this for each player that loads. So if a single page has two separate video players, you’ll need to push twice. However, if the same video player switches to a new video, you do not need to make this push, as the strategy interface should take care of new video loads.
In order to use the Video Pinger, you must modify the Chartbeat code already on your site. You'll want to switch the Chartbeat code to load chartbeat_video.js
instead of chartbeat.js
. The chartbeat_video.js
file includes both Publishing and Video tracking capabilities.
Your complete Chartbeat code will look something like this:
Review our JavaScript configuration variables and add them to the Chartbeat code snippet for your website if they apply to your video player implementation.