Player Layer uses adapters to connect itself to your video player. The default adapter relies on compatibility with W3C DOM standards as detailed in the Custom Adapter References. For example, video.js and Brightcove players adhere to these standards.
Where your player varies, it will require a custom adapter.
If you want we can create a custom adapter for your specific player so you don't have to. Please speak to your relationship manager to discuss creating a custom adapter.
An example of what a custom adapter should look like:
constAbstractAdapter=function (player, playerLayer) {// Constructor// // Implement all necessary wiring here// notifies Player Layer that player is ready// by this time metadata should be preloaded including "name" and "duration"playerLayer.playerReady()// resume/start player layer playbackplayerLayer.play()// pause player layer playbackplayerLayer.pause()// notifies player layer that vide playback endedplayerLayer.ended()// notifies player layer that advert playback startedplayerLayer.advStarted()// notifies player layer that advert playback endedplayerLayer.advEnded()return {// resume/start video playbackplay()// pause video playbackpause()// get current timecodegetTimeCode()// getMediaInfo()// currently we require `name` and `duration` to be returned// {name: 'Video title', duration: 120}getMediaInfo()// destructor// it is highly recommended to implement destructor // to tear down all hooksdestroy() };}
An example of a custom adapter made for the YouTube video player:
<divid="player-container"></div>// instantiate YouTube player// parameters omitted as they can vary from implementationconstplayer=newYT.Player('player-container', {...});constCustomYoutubeAdapter= (player, playerLayer) => {// wiring up vide player's eventsplayer.addEventListener('onStateChange', (state) => {switch(state) {caseYT.PlayerState.PLAYING:returnplayerLayer.play();caseYT.PlayerState.PAUSED:returnplayerLayer.pause(); } });// and so on...return {play: () =>player.playVideo(),// pause video playbackpause: () =>player.pauseVideo(),// get current timecodegetTimeCode: () =>player.getCurrentTime(),// getMediaInfo()// currently we require `name` and `duration` to be returned// { name: 'Video title', duration: 120 }getMediaInfo: () => ({ name:'Video title', duration:player.getDuration() }),// destructordestroy: () => {// unsubscribe form previously wired up eventsplayer.removeEventListener('onStateChange'); } }};constpl=newPlayerLayer({ clientKey:"my-client-key", playerAdapter: CustomYoutubeAdapter, playerContainer:document.getElementById("player-container"), playerInstance: player});