jwplayer events

How to Use JW Player’s API to detect and verify when video advertising events clicked or not.

206

Below are some progressive events while running any video advertisement on jw-player source

The advertisement impression was fired.
The advertisement completes in  seconds.
The user clicked the advertisement.
(no advertisement skip yet)
(no advertisement complete yet)..
To capture those events we can use below written code
const jwplayerobj = jwplayer(‘player’).setup({
playlist: ‘playlist url’,
advertising: {
client: ‘vast’,
tag: ‘path of file’
}
});

const jwadImpression = document.getElementById(‘impression’);
jwplayerobj.on(‘jwadImpression’, function() {
jwadImpression.checked = true;
});

const jwadSkipped = document.getElementById(‘skip’);
jwplayerobj.on(‘jwadSkipped’, function() {
jwadSkipped.checked = true;
});

const jwprogress = document.getElementById(‘progress’);
const jwremaining = document.getElementById(‘remaining’);
jwplayerobj.on(‘adTime’, function(event) {
const { duration, position } = event;
if (!jwprogress.checked) {
jwprogress.checked = true;
}
jwremaining.value = Math.ceil(duration – position);
});

const jwadClick = document.getElementById(‘click’);
jwplayerobj.on(‘jwadClick’, function() {
jwadClick.checked = true;
});

const jwadComplete = document.getElementById(‘complete’);
jwplayerobj.on(‘jwadComplete’, function() {
jwadComplete.checked = true;
});

· ·


Related Articles & Comments

Leave a Comment

Your email address will not be published. Required fields are marked *