SDK that offers easy access for developers to video sources and glomex tracking events
npm install @glomex/content-sdk-jsnpm install from the root directory first.Using npm:
``bash`
npm install @glomex/content-sdk-js
In a browser:
`html`
Note:
This SDK module uses ES6 syntax and requires the consumer
to use babel compiler and to provide a proper Promise polyfill.
js
const glomexContentSdk = require('@glomex/content-sdk-js');// Fill your config here
const config = {
integrationId: '[INTEGRATION_ID]',
contentId: '[CONTENT_ID]'
};
// glomexContentSdk is asynchronous
// so there is no need to wait for loading in your code
const sdk = glomexContentSdk(config);
const videoSourcesLoaded = sdk.getSources();
// ... other preparations ...
videoSourcesLoaded.then(function(sources) {
const videoPlayer = createOwnVideoPlayer(sources);
// tracking is asyncronous too, so you don't wait here
sdk.trackContentBegin();
// before your video begin
videoPlayer.addEventListener('loadeddata', function() {
// asynchronous operation
sdk.trackAdBegin('preroll');
});
// after your video ended
videoPlayer.addEventListener('ended', function() {
// asynchronous operation
sdk.trackAdBegin('postroll');
});
// play your video
videoPlayer.play();
}, function(error) { // rare you can get an error 'no video'
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.`html
``To learn more about content-sdk visit our Content SDK Integration Guide
---
Made with ♥ by glomex