From 31c816656267efa495d02e7f3429d35d91f9c648 Mon Sep 17 00:00:00 2001 From: Arthur Hulsman Date: Wed, 17 Jan 2018 15:57:10 +0100 Subject: [PATCH] Fixed string literal and position issue of the midroll cue inside the time line. Added a check for the progress element existence. --- src/js/plugins/ads.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/js/plugins/ads.js b/src/js/plugins/ads.js index dcd236a9..0b12a8e7 100644 --- a/src/js/plugins/ads.js +++ b/src/js/plugins/ads.js @@ -159,11 +159,14 @@ class Ads { this.adsCuePoints.forEach((cuePoint) => { if (cuePoint !== 0 && cuePoint !== -1) { const seekElement = this.player.elements.progress; - const cue = utils.createElement('span', { - class: this.player.config.classNames.cues, - }); - cue.style.left = cuePoint.toString() + 'px'; - seekElement.appendChild(cue); + if(seekElement) { + const cuePercentage = 100 / this.player.duration * cuePoint; + const cue = utils.createElement('span', { + class: this.player.config.classNames.cues, + }); + cue.style.left = `${cuePercentage.toString()}%`; + seekElement.appendChild(cue); + } } });