Open DoomTay opened 6 years ago
it happen with vjs7, with 5.19.x the order is correct
can you confirm @DoomTay ?
i think i resolve it, if it can be useful, i noticed in the videojs log that after the first group of midroll, the log not return anymore the string
[ad-scheduler] Main content: X, next trigger: X
so i guess it's not monitoring the timing, i also noticed an error on console:
player.play().ready is not a function
just before an timeUpdateHandler callback, thats trigger the timing monitoring for next trigger.
So i replace:
player.play().ready(function() {
with
player.ready(function() {
and it works like a charm
======================
Checking with group of midroll i also found an other bug, at the end of first ad, on the skip-button remain the "enabled" class, that prevent to show the "Skip this AD >>" text on the next ad.
I change this:
if (timeLeft > 0) { player.ottAdScheduler.skipButton.innerHTML = 'You can skip ad in ' + timeLeft + '...'; if (player.ottAdScheduler.skipButton.classList.contains('enabled')) { player.ottAdScheduler.skipButton.classList.remove('enabled'); } } else { if (!player.ottAdScheduler.skipButton.classList.contains('enabled')) { player.ottAdScheduler.skipButton.classList.add('enabled'); player.ottAdScheduler.skipButton.innerHTML = 'Skip this AD >>'; } }
with
if (timeLeft > 0) { player.ottAdScheduler.skipButton.innerHTML = 'You can skip ad in ' + timeLeft + '...'; if (player.ottAdScheduler.skipButton.classList.contains('enabled')) { player.ottAdScheduler.skipButton.classList.remove('enabled'); } } else { if (!player.ottAdScheduler.skipButton.classList.contains('enabled')) { player.ottAdScheduler.skipButton.classList.add('enabled'); player.ottAdScheduler.skipButton.innerHTML = 'Skip this AD >>'; } }
I don't know about the order being correct, but unfortunately the bug still manifests in videojs v7
try to activate the videojs debug, and in console you should see the current player time and the next ad marker, if not it can't works
VIDEOJS: [ad-scheduler] Main content: 3.9363, next trigger: 11
So at the beginning, I get a stream of something along the lines of VIDEOJS: [ad-scheduler] Main content: 1.028117, next trigger: 229
, which is about 3:49. So then that adblock plays, then when it's done, I get VIDEOJS: [ad-scheduler] Main content: 229.409138, next trigger: 424
, or 7:04. After the first ad is done, I get VIDEOJS: [ad-scheduler] Main content: 424.358169, next trigger: 229
again. After that it's VIDEOJS: [ad-scheduler] Main content: 424.358169, next trigger: 335
for four ads then TypeError: vast is null
Try to check the version of your libraries. I'm using: Video.js 7.6.3 videojs-ad-scheduler - v0.1.0 - 2016-5-25 videojs-contrib-ads @version 6.6.4 last vast-client (i'v no version) last vmap-client (i'v no version)
I've made many corrections and try with different version of contrib-ads, e.g.: with first script version the trigger(nopreroll) not working because no "nopreroll" implementation was in contrib-ads.
Also the XML is important, i've had some problems when XML output was minify
I checked the versions of all of the libraries and the bug still shows up, at least when using an XML exactly like what I've posted here
I've also found out that if sortedOffset.sort();
is replaced with sortedOffset.sort(function(a, b){return a-b});
the bug goes away
Here is an example VMAP. It was made from a client-side maker I've been working on, and apart from the tag URLs and timecodes, the output looks just like this
And the first pod only shows two ads, and all the rest are moved to the last spot
And here's the log when debug is set to true
Upon further digging, it seems the cause is
https://github.com/stevennick/videojs-ad-scheduler/blob/6133bc3d912eced3738b23701382a38714706c9a/src/videojs-ad-scheduler.js#L337
which sorts numbers like strings. What is the purpose of "sorting" the array anyway?