content-sdk-js
An SDK that offers easy access for developers to video sources and to transfer tracking events to glomex.
Demo
To run the example project, clone the repo, and run npm install
from the root directory first.
Installation
Using npm:
npm install @glomex/content-sdk-js
Using yarn:
yarn add @glomex/content-sdk-js
In a browser:
<script src="//player.glomex.com/content-sdk/1/glomex.content-sdk.js"></script>
Note:
This SDK module uses ES6 syntax and requires the consumer
to use babel compiler and to provide a proper Promise polyfill.
Usage
const glomexContentSdk = require('@glomex/content-sdk-js');
const config = {
integrationId: '[INTEGRATION_ID]',
contentId: '[CONTENT_ID]'
};
const sdk = glomexContentSdk(config);
const videoSourcesLoaded = sdk.getSources();
videoSourcesLoaded.then(function(sources) {
const videoPlayer = createOwnVideoPlayer(sources);
sdk.trackContentBegin();
videoPlayer.addEventListener('loadeddata', function() {
sdk.trackAdBegin('preroll');
});
videoPlayer.addEventListener('ended', function() {
sdk.trackAdBegin('postroll');
});
videoPlayer.play();
}, function(error) {
console.log(error);
});
In case you don't have any video player on the page, use our script
for creating HTML5 video player and getting this example working.
Otherwise the createOwnVideoPlayer
function should return a video player object.
<script src="//player.glomex.com/content-sdk/1/create-video-player.js"></script>
More
To learn more about content-sdk visit our Content SDK Integration Guide
Made with ♥ by glomex