Fix for cue points missing

This commit is contained in:
Sam Potts 2019-02-07 23:45:19 +11:00
parent eb628c8e4f
commit dbd2136bac
18 changed files with 408 additions and 457 deletions

133
demo/dist/demo.js vendored
View File

@ -4796,28 +4796,6 @@ typeof navigator === "object" && (function () {
ui: ui
};
},
// Detect support for autoplay
/* autoplay: (() => {
const video = document.createElement('video');
video.src = 'https://cdn.plyr.io/static/blank.mp4';
const promise = video.play();
if (is.promise(promise)) {
console.warn('PROMISE', promise);
promise
.then(() => {
console.warn('supported');
return true;
})
.catch(() => {
console.warn('not supported');
return false;
});
} else {
console.warn('supported - no promise');
return true;
}
})(), */
// Picture-in-picture support
// Safari & Chrome only currently
pip: function () {
@ -10288,25 +10266,7 @@ typeof navigator === "object" && (function () {
this.manager = event.getAdsManager(this.player, settings); // Get the cue points for any mid-rolls by filtering out the pre- and post-roll
this.cuePoints = this.manager.getCuePoints(); // Add advertisement cue's within the time line if available
if (!is.empty(this.cuePoints)) {
this.cuePoints.forEach(function (cuePoint) {
if (cuePoint !== 0 && cuePoint !== -1 && cuePoint < _this6.player.duration) {
var seekElement = _this6.player.elements.progress;
if (is.element(seekElement)) {
var cuePercentage = 100 / _this6.player.duration * cuePoint;
var cue = createElement('span', {
class: _this6.player.config.classNames.cues
});
cue.style.left = "".concat(cuePercentage.toString(), "%");
seekElement.appendChild(cue);
}
}
});
} // Set volume to match player
this.cuePoints = this.manager.getCuePoints(); // Set volume to match player
this.manager.setVolume(this.player.volume); // Add listeners to the required events
// Advertisement error events
@ -10323,6 +10283,29 @@ typeof navigator === "object" && (function () {
this.trigger('loaded');
}
}, {
key: "addCuePoints",
value: function addCuePoints() {
var _this7 = this;
// Add advertisement cue's within the time line if available
if (!is.empty(this.cuePoints)) {
this.cuePoints.forEach(function (cuePoint) {
if (cuePoint !== 0 && cuePoint !== -1 && cuePoint < _this7.player.duration) {
var seekElement = _this7.player.elements.progress;
if (is.element(seekElement)) {
var cuePercentage = 100 / _this7.player.duration * cuePoint;
var cue = createElement('span', {
class: _this7.player.config.classNames.cues
});
cue.style.left = "".concat(cuePercentage.toString(), "%");
seekElement.appendChild(cue);
}
}
});
}
}
/**
* This is where all the event handling takes place. Retrieve the ad from the event. Some
* events (e.g. ALL_ADS_COMPLETED) don't have the ad object associated
@ -10333,7 +10316,7 @@ typeof navigator === "object" && (function () {
}, {
key: "onAdEvent",
value: function onAdEvent(event) {
var _this7 = this;
var _this8 = this;
var container = this.player.elements.container; // Retrieve the ad from the event. Some events (e.g. ALL_ADS_COMPLETED)
// don't have ad object associated
@ -10343,7 +10326,7 @@ typeof navigator === "object" && (function () {
var dispatchEvent = function dispatchEvent(type) {
var event = "ads".concat(type.replace(/_/g, '').toLowerCase());
triggerEvent.call(_this7.player, _this7.player.media, event);
triggerEvent.call(_this8.player, _this8.player.media, event);
};
switch (event.type) {
@ -10452,37 +10435,39 @@ typeof navigator === "object" && (function () {
}, {
key: "listeners",
value: function listeners() {
var _this8 = this;
var _this9 = this;
var container = this.player.elements.container;
var time; // Add listeners to the required events
var time;
this.player.on('canplay', function () {
_this9.addCuePoints();
});
this.player.on('ended', function () {
_this8.loader.contentComplete();
_this9.loader.contentComplete();
});
this.player.on('timeupdate', function () {
time = _this8.player.currentTime;
time = _this9.player.currentTime;
});
this.player.on('seeked', function () {
var seekedTime = _this8.player.currentTime;
var seekedTime = _this9.player.currentTime;
if (is.empty(_this8.cuePoints)) {
if (is.empty(_this9.cuePoints)) {
return;
}
_this8.cuePoints.forEach(function (cuePoint, index) {
_this9.cuePoints.forEach(function (cuePoint, index) {
if (time < cuePoint && cuePoint < seekedTime) {
_this8.manager.discardAdBreak();
_this9.manager.discardAdBreak();
_this8.cuePoints.splice(index, 1);
_this9.cuePoints.splice(index, 1);
}
});
}); // Listen to the resizing of the window. And resize ad accordingly
// TODO: eventually implement ResizeObserver
window.addEventListener('resize', function () {
if (_this8.manager) {
_this8.manager.resize(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL);
if (_this9.manager) {
_this9.manager.resize(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL);
}
});
}
@ -10493,7 +10478,7 @@ typeof navigator === "object" && (function () {
}, {
key: "play",
value: function play() {
var _this9 = this;
var _this10 = this;
var container = this.player.elements.container;
@ -10504,23 +10489,23 @@ typeof navigator === "object" && (function () {
this.managerPromise.then(function () {
// Initialize the container. Must be done via a user action on mobile devices
_this9.elements.displayContainer.initialize();
_this10.elements.displayContainer.initialize();
try {
if (!_this9.initialized) {
if (!_this10.initialized) {
// Initialize the ads manager. Ad rules playlist will start at this time
_this9.manager.init(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL); // Call play to start showing the ad. Single video and overlay ads will
_this10.manager.init(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL); // Call play to start showing the ad. Single video and overlay ads will
// start at this time; the call will be ignored for ad rules
_this9.manager.start();
_this10.manager.start();
}
_this9.initialized = true;
_this10.initialized = true;
} catch (adError) {
// An error may be thrown if there was a problem with the
// VAST response
_this9.onAdError(adError);
_this10.onAdError(adError);
}
}).catch(function () {});
}
@ -10579,23 +10564,23 @@ typeof navigator === "object" && (function () {
}, {
key: "loadAds",
value: function loadAds() {
var _this10 = this;
var _this11 = this;
// Tell our adsManager to go bye bye
this.managerPromise.then(function () {
// Destroy our adsManager
if (_this10.manager) {
_this10.manager.destroy();
if (_this11.manager) {
_this11.manager.destroy();
} // Re-set our adsManager promises
_this10.managerPromise = new Promise(function (resolve) {
_this10.on('loaded', resolve);
_this11.managerPromise = new Promise(function (resolve) {
_this11.on('loaded', resolve);
_this10.player.debug.log(_this10.manager);
_this11.player.debug.log(_this11.manager);
}); // Now request some new advertisements
_this10.requestAds();
_this11.requestAds();
}).catch(function () {});
}
/**
@ -10606,7 +10591,7 @@ typeof navigator === "object" && (function () {
}, {
key: "trigger",
value: function trigger(event) {
var _this11 = this;
var _this12 = this;
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
@ -10617,7 +10602,7 @@ typeof navigator === "object" && (function () {
if (is.array(handlers)) {
handlers.forEach(function (handler) {
if (is.function(handler)) {
handler.apply(_this11, args);
handler.apply(_this12, args);
}
});
}
@ -10651,13 +10636,13 @@ typeof navigator === "object" && (function () {
}, {
key: "startSafetyTimer",
value: function startSafetyTimer(time, from) {
var _this12 = this;
var _this13 = this;
this.player.debug.log("Safety timer invoked from: ".concat(from));
this.safetyTimer = setTimeout(function () {
_this12.cancel();
_this13.cancel();
_this12.clearSafetyTimer('startSafetyTimer()');
_this13.clearSafetyTimer('startSafetyTimer()');
}, time);
}
/**

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

133
dist/plyr.js vendored
View File

@ -711,28 +711,6 @@ typeof navigator === "object" && (function (global, factory) {
ui: ui
};
},
// Detect support for autoplay
/* autoplay: (() => {
const video = document.createElement('video');
video.src = 'https://cdn.plyr.io/static/blank.mp4';
const promise = video.play();
if (is.promise(promise)) {
console.warn('PROMISE', promise);
promise
.then(() => {
console.warn('supported');
return true;
})
.catch(() => {
console.warn('not supported');
return false;
});
} else {
console.warn('supported - no promise');
return true;
}
})(), */
// Picture-in-picture support
// Safari & Chrome only currently
pip: function () {
@ -6209,25 +6187,7 @@ typeof navigator === "object" && (function (global, factory) {
this.manager = event.getAdsManager(this.player, settings); // Get the cue points for any mid-rolls by filtering out the pre- and post-roll
this.cuePoints = this.manager.getCuePoints(); // Add advertisement cue's within the time line if available
if (!is.empty(this.cuePoints)) {
this.cuePoints.forEach(function (cuePoint) {
if (cuePoint !== 0 && cuePoint !== -1 && cuePoint < _this6.player.duration) {
var seekElement = _this6.player.elements.progress;
if (is.element(seekElement)) {
var cuePercentage = 100 / _this6.player.duration * cuePoint;
var cue = createElement('span', {
class: _this6.player.config.classNames.cues
});
cue.style.left = "".concat(cuePercentage.toString(), "%");
seekElement.appendChild(cue);
}
}
});
} // Set volume to match player
this.cuePoints = this.manager.getCuePoints(); // Set volume to match player
this.manager.setVolume(this.player.volume); // Add listeners to the required events
// Advertisement error events
@ -6244,6 +6204,29 @@ typeof navigator === "object" && (function (global, factory) {
this.trigger('loaded');
}
}, {
key: "addCuePoints",
value: function addCuePoints() {
var _this7 = this;
// Add advertisement cue's within the time line if available
if (!is.empty(this.cuePoints)) {
this.cuePoints.forEach(function (cuePoint) {
if (cuePoint !== 0 && cuePoint !== -1 && cuePoint < _this7.player.duration) {
var seekElement = _this7.player.elements.progress;
if (is.element(seekElement)) {
var cuePercentage = 100 / _this7.player.duration * cuePoint;
var cue = createElement('span', {
class: _this7.player.config.classNames.cues
});
cue.style.left = "".concat(cuePercentage.toString(), "%");
seekElement.appendChild(cue);
}
}
});
}
}
/**
* This is where all the event handling takes place. Retrieve the ad from the event. Some
* events (e.g. ALL_ADS_COMPLETED) don't have the ad object associated
@ -6254,7 +6237,7 @@ typeof navigator === "object" && (function (global, factory) {
}, {
key: "onAdEvent",
value: function onAdEvent(event) {
var _this7 = this;
var _this8 = this;
var container = this.player.elements.container; // Retrieve the ad from the event. Some events (e.g. ALL_ADS_COMPLETED)
// don't have ad object associated
@ -6264,7 +6247,7 @@ typeof navigator === "object" && (function (global, factory) {
var dispatchEvent = function dispatchEvent(type) {
var event = "ads".concat(type.replace(/_/g, '').toLowerCase());
triggerEvent.call(_this7.player, _this7.player.media, event);
triggerEvent.call(_this8.player, _this8.player.media, event);
};
switch (event.type) {
@ -6373,37 +6356,39 @@ typeof navigator === "object" && (function (global, factory) {
}, {
key: "listeners",
value: function listeners() {
var _this8 = this;
var _this9 = this;
var container = this.player.elements.container;
var time; // Add listeners to the required events
var time;
this.player.on('canplay', function () {
_this9.addCuePoints();
});
this.player.on('ended', function () {
_this8.loader.contentComplete();
_this9.loader.contentComplete();
});
this.player.on('timeupdate', function () {
time = _this8.player.currentTime;
time = _this9.player.currentTime;
});
this.player.on('seeked', function () {
var seekedTime = _this8.player.currentTime;
var seekedTime = _this9.player.currentTime;
if (is.empty(_this8.cuePoints)) {
if (is.empty(_this9.cuePoints)) {
return;
}
_this8.cuePoints.forEach(function (cuePoint, index) {
_this9.cuePoints.forEach(function (cuePoint, index) {
if (time < cuePoint && cuePoint < seekedTime) {
_this8.manager.discardAdBreak();
_this9.manager.discardAdBreak();
_this8.cuePoints.splice(index, 1);
_this9.cuePoints.splice(index, 1);
}
});
}); // Listen to the resizing of the window. And resize ad accordingly
// TODO: eventually implement ResizeObserver
window.addEventListener('resize', function () {
if (_this8.manager) {
_this8.manager.resize(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL);
if (_this9.manager) {
_this9.manager.resize(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL);
}
});
}
@ -6414,7 +6399,7 @@ typeof navigator === "object" && (function (global, factory) {
}, {
key: "play",
value: function play() {
var _this9 = this;
var _this10 = this;
var container = this.player.elements.container;
@ -6425,23 +6410,23 @@ typeof navigator === "object" && (function (global, factory) {
this.managerPromise.then(function () {
// Initialize the container. Must be done via a user action on mobile devices
_this9.elements.displayContainer.initialize();
_this10.elements.displayContainer.initialize();
try {
if (!_this9.initialized) {
if (!_this10.initialized) {
// Initialize the ads manager. Ad rules playlist will start at this time
_this9.manager.init(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL); // Call play to start showing the ad. Single video and overlay ads will
_this10.manager.init(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL); // Call play to start showing the ad. Single video and overlay ads will
// start at this time; the call will be ignored for ad rules
_this9.manager.start();
_this10.manager.start();
}
_this9.initialized = true;
_this10.initialized = true;
} catch (adError) {
// An error may be thrown if there was a problem with the
// VAST response
_this9.onAdError(adError);
_this10.onAdError(adError);
}
}).catch(function () {});
}
@ -6500,23 +6485,23 @@ typeof navigator === "object" && (function (global, factory) {
}, {
key: "loadAds",
value: function loadAds() {
var _this10 = this;
var _this11 = this;
// Tell our adsManager to go bye bye
this.managerPromise.then(function () {
// Destroy our adsManager
if (_this10.manager) {
_this10.manager.destroy();
if (_this11.manager) {
_this11.manager.destroy();
} // Re-set our adsManager promises
_this10.managerPromise = new Promise(function (resolve) {
_this10.on('loaded', resolve);
_this11.managerPromise = new Promise(function (resolve) {
_this11.on('loaded', resolve);
_this10.player.debug.log(_this10.manager);
_this11.player.debug.log(_this11.manager);
}); // Now request some new advertisements
_this10.requestAds();
_this11.requestAds();
}).catch(function () {});
}
/**
@ -6527,7 +6512,7 @@ typeof navigator === "object" && (function (global, factory) {
}, {
key: "trigger",
value: function trigger(event) {
var _this11 = this;
var _this12 = this;
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
@ -6538,7 +6523,7 @@ typeof navigator === "object" && (function (global, factory) {
if (is.array(handlers)) {
handlers.forEach(function (handler) {
if (is.function(handler)) {
handler.apply(_this11, args);
handler.apply(_this12, args);
}
});
}
@ -6572,13 +6557,13 @@ typeof navigator === "object" && (function (global, factory) {
}, {
key: "startSafetyTimer",
value: function startSafetyTimer(time, from) {
var _this12 = this;
var _this13 = this;
this.player.debug.log("Safety timer invoked from: ".concat(from));
this.safetyTimer = setTimeout(function () {
_this12.cancel();
_this13.cancel();
_this12.clearSafetyTimer('startSafetyTimer()');
_this13.clearSafetyTimer('startSafetyTimer()');
}, time);
}
/**

2
dist/plyr.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/plyr.min.mjs vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

133
dist/plyr.mjs vendored
View File

@ -705,28 +705,6 @@ var support = {
ui: ui
};
},
// Detect support for autoplay
/* autoplay: (() => {
const video = document.createElement('video');
video.src = 'https://cdn.plyr.io/static/blank.mp4';
const promise = video.play();
if (is.promise(promise)) {
console.warn('PROMISE', promise);
promise
.then(() => {
console.warn('supported');
return true;
})
.catch(() => {
console.warn('not supported');
return false;
});
} else {
console.warn('supported - no promise');
return true;
}
})(), */
// Picture-in-picture support
// Safari & Chrome only currently
pip: function () {
@ -6203,25 +6181,7 @@ function () {
this.manager = event.getAdsManager(this.player, settings); // Get the cue points for any mid-rolls by filtering out the pre- and post-roll
this.cuePoints = this.manager.getCuePoints(); // Add advertisement cue's within the time line if available
if (!is.empty(this.cuePoints)) {
this.cuePoints.forEach(function (cuePoint) {
if (cuePoint !== 0 && cuePoint !== -1 && cuePoint < _this6.player.duration) {
var seekElement = _this6.player.elements.progress;
if (is.element(seekElement)) {
var cuePercentage = 100 / _this6.player.duration * cuePoint;
var cue = createElement('span', {
class: _this6.player.config.classNames.cues
});
cue.style.left = "".concat(cuePercentage.toString(), "%");
seekElement.appendChild(cue);
}
}
});
} // Set volume to match player
this.cuePoints = this.manager.getCuePoints(); // Set volume to match player
this.manager.setVolume(this.player.volume); // Add listeners to the required events
// Advertisement error events
@ -6238,6 +6198,29 @@ function () {
this.trigger('loaded');
}
}, {
key: "addCuePoints",
value: function addCuePoints() {
var _this7 = this;
// Add advertisement cue's within the time line if available
if (!is.empty(this.cuePoints)) {
this.cuePoints.forEach(function (cuePoint) {
if (cuePoint !== 0 && cuePoint !== -1 && cuePoint < _this7.player.duration) {
var seekElement = _this7.player.elements.progress;
if (is.element(seekElement)) {
var cuePercentage = 100 / _this7.player.duration * cuePoint;
var cue = createElement('span', {
class: _this7.player.config.classNames.cues
});
cue.style.left = "".concat(cuePercentage.toString(), "%");
seekElement.appendChild(cue);
}
}
});
}
}
/**
* This is where all the event handling takes place. Retrieve the ad from the event. Some
* events (e.g. ALL_ADS_COMPLETED) don't have the ad object associated
@ -6248,7 +6231,7 @@ function () {
}, {
key: "onAdEvent",
value: function onAdEvent(event) {
var _this7 = this;
var _this8 = this;
var container = this.player.elements.container; // Retrieve the ad from the event. Some events (e.g. ALL_ADS_COMPLETED)
// don't have ad object associated
@ -6258,7 +6241,7 @@ function () {
var dispatchEvent = function dispatchEvent(type) {
var event = "ads".concat(type.replace(/_/g, '').toLowerCase());
triggerEvent.call(_this7.player, _this7.player.media, event);
triggerEvent.call(_this8.player, _this8.player.media, event);
};
switch (event.type) {
@ -6367,37 +6350,39 @@ function () {
}, {
key: "listeners",
value: function listeners() {
var _this8 = this;
var _this9 = this;
var container = this.player.elements.container;
var time; // Add listeners to the required events
var time;
this.player.on('canplay', function () {
_this9.addCuePoints();
});
this.player.on('ended', function () {
_this8.loader.contentComplete();
_this9.loader.contentComplete();
});
this.player.on('timeupdate', function () {
time = _this8.player.currentTime;
time = _this9.player.currentTime;
});
this.player.on('seeked', function () {
var seekedTime = _this8.player.currentTime;
var seekedTime = _this9.player.currentTime;
if (is.empty(_this8.cuePoints)) {
if (is.empty(_this9.cuePoints)) {
return;
}
_this8.cuePoints.forEach(function (cuePoint, index) {
_this9.cuePoints.forEach(function (cuePoint, index) {
if (time < cuePoint && cuePoint < seekedTime) {
_this8.manager.discardAdBreak();
_this9.manager.discardAdBreak();
_this8.cuePoints.splice(index, 1);
_this9.cuePoints.splice(index, 1);
}
});
}); // Listen to the resizing of the window. And resize ad accordingly
// TODO: eventually implement ResizeObserver
window.addEventListener('resize', function () {
if (_this8.manager) {
_this8.manager.resize(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL);
if (_this9.manager) {
_this9.manager.resize(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL);
}
});
}
@ -6408,7 +6393,7 @@ function () {
}, {
key: "play",
value: function play() {
var _this9 = this;
var _this10 = this;
var container = this.player.elements.container;
@ -6419,23 +6404,23 @@ function () {
this.managerPromise.then(function () {
// Initialize the container. Must be done via a user action on mobile devices
_this9.elements.displayContainer.initialize();
_this10.elements.displayContainer.initialize();
try {
if (!_this9.initialized) {
if (!_this10.initialized) {
// Initialize the ads manager. Ad rules playlist will start at this time
_this9.manager.init(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL); // Call play to start showing the ad. Single video and overlay ads will
_this10.manager.init(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL); // Call play to start showing the ad. Single video and overlay ads will
// start at this time; the call will be ignored for ad rules
_this9.manager.start();
_this10.manager.start();
}
_this9.initialized = true;
_this10.initialized = true;
} catch (adError) {
// An error may be thrown if there was a problem with the
// VAST response
_this9.onAdError(adError);
_this10.onAdError(adError);
}
}).catch(function () {});
}
@ -6494,23 +6479,23 @@ function () {
}, {
key: "loadAds",
value: function loadAds() {
var _this10 = this;
var _this11 = this;
// Tell our adsManager to go bye bye
this.managerPromise.then(function () {
// Destroy our adsManager
if (_this10.manager) {
_this10.manager.destroy();
if (_this11.manager) {
_this11.manager.destroy();
} // Re-set our adsManager promises
_this10.managerPromise = new Promise(function (resolve) {
_this10.on('loaded', resolve);
_this11.managerPromise = new Promise(function (resolve) {
_this11.on('loaded', resolve);
_this10.player.debug.log(_this10.manager);
_this11.player.debug.log(_this11.manager);
}); // Now request some new advertisements
_this10.requestAds();
_this11.requestAds();
}).catch(function () {});
}
/**
@ -6521,7 +6506,7 @@ function () {
}, {
key: "trigger",
value: function trigger(event) {
var _this11 = this;
var _this12 = this;
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
@ -6532,7 +6517,7 @@ function () {
if (is.array(handlers)) {
handlers.forEach(function (handler) {
if (is.function(handler)) {
handler.apply(_this11, args);
handler.apply(_this12, args);
}
});
}
@ -6566,13 +6551,13 @@ function () {
}, {
key: "startSafetyTimer",
value: function startSafetyTimer(time, from) {
var _this12 = this;
var _this13 = this;
this.player.debug.log("Safety timer invoked from: ".concat(from));
this.safetyTimer = setTimeout(function () {
_this12.cancel();
_this13.cancel();
_this12.clearSafetyTimer('startSafetyTimer()');
_this13.clearSafetyTimer('startSafetyTimer()');
}, time);
}
/**

View File

@ -574,7 +574,7 @@ typeof navigator === "object" && (function (global, factory) {
});
var _core = createCommonjsModule(function (module) {
var core = module.exports = { version: '2.6.3' };
var core = module.exports = { version: '2.6.4' };
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
});
var _core_1 = _core.version;
@ -670,14 +670,31 @@ typeof navigator === "object" && (function (global, factory) {
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
};
var _library = false;
var _shared = createCommonjsModule(function (module) {
var SHARED = '__core-js_shared__';
var store = _global[SHARED] || (_global[SHARED] = {});
(module.exports = function (key, value) {
return store[key] || (store[key] = value !== undefined ? value : {});
})('versions', []).push({
version: _core.version,
mode: 'global',
copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
});
});
var _functionToString = _shared('native-function-to-string', Function.toString);
var _redefine = createCommonjsModule(function (module) {
var SRC = _uid('src');
var TO_STRING = 'toString';
var $toString = Function[TO_STRING];
var TPL = ('' + $toString).split(TO_STRING);
var TPL = ('' + _functionToString).split(TO_STRING);
_core.inspectSource = function (it) {
return $toString.call(it);
return _functionToString.call(it);
};
(module.exports = function (O, key, val, safe) {
@ -697,7 +714,7 @@ typeof navigator === "object" && (function (global, factory) {
}
// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
})(Function.prototype, TO_STRING, function toString() {
return typeof this == 'function' && this[SRC] || $toString.call(this);
return typeof this == 'function' && this[SRC] || _functionToString.call(this);
});
});
@ -767,21 +784,6 @@ typeof navigator === "object" && (function (global, factory) {
var _iterators = {};
var _library = false;
var _shared = createCommonjsModule(function (module) {
var SHARED = '__core-js_shared__';
var store = _global[SHARED] || (_global[SHARED] = {});
(module.exports = function (key, value) {
return store[key] || (store[key] = value !== undefined ? value : {});
})('versions', []).push({
version: _core.version,
mode: 'global',
copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
});
});
var _wks = createCommonjsModule(function (module) {
var store = _shared('wks');
@ -2124,6 +2126,7 @@ typeof navigator === "object" && (function (global, factory) {
};
var es6_weakMap = createCommonjsModule(function (module) {
var each = _arrayMethods(0);
@ -2131,12 +2134,12 @@ typeof navigator === "object" && (function (global, factory) {
var NATIVE_WEAK_MAP = _validateCollection;
var IS_IE11 = !_global.ActiveXObject && 'ActiveXObject' in _global;
var WEAK_MAP = 'WeakMap';
var getWeak = _meta.getWeak;
var isExtensible = Object.isExtensible;
var uncaughtFrozenStore = _collectionWeak.ufstore;
var tmp = {};
var InternalMap;
var wrapper = function (get) {
@ -2164,7 +2167,7 @@ typeof navigator === "object" && (function (global, factory) {
var $WeakMap = module.exports = _collection(WEAK_MAP, wrapper, methods, _collectionWeak, true, true);
// IE11 WeakMap frozen keys fix
if (_fails(function () { return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7; })) {
if (NATIVE_WEAK_MAP && IS_IE11) {
InternalMap = _collectionWeak.getConstructor(wrapper, WEAK_MAP);
_objectAssign(InternalMap.prototype, methods);
_meta.NEED = true;
@ -3728,28 +3731,6 @@ typeof navigator === "object" && (function (global, factory) {
ui: ui
};
},
// Detect support for autoplay
/* autoplay: (() => {
const video = document.createElement('video');
video.src = 'https://cdn.plyr.io/static/blank.mp4';
const promise = video.play();
if (is.promise(promise)) {
console.warn('PROMISE', promise);
promise
.then(() => {
console.warn('supported');
return true;
})
.catch(() => {
console.warn('not supported');
return false;
});
} else {
console.warn('supported - no promise');
return true;
}
})(), */
// Picture-in-picture support
// Safari & Chrome only currently
pip: function () {
@ -9323,25 +9304,7 @@ typeof navigator === "object" && (function (global, factory) {
this.manager = event.getAdsManager(this.player, settings); // Get the cue points for any mid-rolls by filtering out the pre- and post-roll
this.cuePoints = this.manager.getCuePoints(); // Add advertisement cue's within the time line if available
if (!is$1.empty(this.cuePoints)) {
this.cuePoints.forEach(function (cuePoint) {
if (cuePoint !== 0 && cuePoint !== -1 && cuePoint < _this6.player.duration) {
var seekElement = _this6.player.elements.progress;
if (is$1.element(seekElement)) {
var cuePercentage = 100 / _this6.player.duration * cuePoint;
var cue = createElement('span', {
class: _this6.player.config.classNames.cues
});
cue.style.left = "".concat(cuePercentage.toString(), "%");
seekElement.appendChild(cue);
}
}
});
} // Set volume to match player
this.cuePoints = this.manager.getCuePoints(); // Set volume to match player
this.manager.setVolume(this.player.volume); // Add listeners to the required events
// Advertisement error events
@ -9358,6 +9321,29 @@ typeof navigator === "object" && (function (global, factory) {
this.trigger('loaded');
}
}, {
key: "addCuePoints",
value: function addCuePoints() {
var _this7 = this;
// Add advertisement cue's within the time line if available
if (!is$1.empty(this.cuePoints)) {
this.cuePoints.forEach(function (cuePoint) {
if (cuePoint !== 0 && cuePoint !== -1 && cuePoint < _this7.player.duration) {
var seekElement = _this7.player.elements.progress;
if (is$1.element(seekElement)) {
var cuePercentage = 100 / _this7.player.duration * cuePoint;
var cue = createElement('span', {
class: _this7.player.config.classNames.cues
});
cue.style.left = "".concat(cuePercentage.toString(), "%");
seekElement.appendChild(cue);
}
}
});
}
}
/**
* This is where all the event handling takes place. Retrieve the ad from the event. Some
* events (e.g. ALL_ADS_COMPLETED) don't have the ad object associated
@ -9368,7 +9354,7 @@ typeof navigator === "object" && (function (global, factory) {
}, {
key: "onAdEvent",
value: function onAdEvent(event) {
var _this7 = this;
var _this8 = this;
var container = this.player.elements.container; // Retrieve the ad from the event. Some events (e.g. ALL_ADS_COMPLETED)
// don't have ad object associated
@ -9378,7 +9364,7 @@ typeof navigator === "object" && (function (global, factory) {
var dispatchEvent = function dispatchEvent(type) {
var event = "ads".concat(type.replace(/_/g, '').toLowerCase());
triggerEvent.call(_this7.player, _this7.player.media, event);
triggerEvent.call(_this8.player, _this8.player.media, event);
};
switch (event.type) {
@ -9487,37 +9473,39 @@ typeof navigator === "object" && (function (global, factory) {
}, {
key: "listeners",
value: function listeners() {
var _this8 = this;
var _this9 = this;
var container = this.player.elements.container;
var time; // Add listeners to the required events
var time;
this.player.on('canplay', function () {
_this9.addCuePoints();
});
this.player.on('ended', function () {
_this8.loader.contentComplete();
_this9.loader.contentComplete();
});
this.player.on('timeupdate', function () {
time = _this8.player.currentTime;
time = _this9.player.currentTime;
});
this.player.on('seeked', function () {
var seekedTime = _this8.player.currentTime;
var seekedTime = _this9.player.currentTime;
if (is$1.empty(_this8.cuePoints)) {
if (is$1.empty(_this9.cuePoints)) {
return;
}
_this8.cuePoints.forEach(function (cuePoint, index) {
_this9.cuePoints.forEach(function (cuePoint, index) {
if (time < cuePoint && cuePoint < seekedTime) {
_this8.manager.discardAdBreak();
_this9.manager.discardAdBreak();
_this8.cuePoints.splice(index, 1);
_this9.cuePoints.splice(index, 1);
}
});
}); // Listen to the resizing of the window. And resize ad accordingly
// TODO: eventually implement ResizeObserver
window.addEventListener('resize', function () {
if (_this8.manager) {
_this8.manager.resize(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL);
if (_this9.manager) {
_this9.manager.resize(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL);
}
});
}
@ -9528,7 +9516,7 @@ typeof navigator === "object" && (function (global, factory) {
}, {
key: "play",
value: function play() {
var _this9 = this;
var _this10 = this;
var container = this.player.elements.container;
@ -9539,23 +9527,23 @@ typeof navigator === "object" && (function (global, factory) {
this.managerPromise.then(function () {
// Initialize the container. Must be done via a user action on mobile devices
_this9.elements.displayContainer.initialize();
_this10.elements.displayContainer.initialize();
try {
if (!_this9.initialized) {
if (!_this10.initialized) {
// Initialize the ads manager. Ad rules playlist will start at this time
_this9.manager.init(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL); // Call play to start showing the ad. Single video and overlay ads will
_this10.manager.init(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL); // Call play to start showing the ad. Single video and overlay ads will
// start at this time; the call will be ignored for ad rules
_this9.manager.start();
_this10.manager.start();
}
_this9.initialized = true;
_this10.initialized = true;
} catch (adError) {
// An error may be thrown if there was a problem with the
// VAST response
_this9.onAdError(adError);
_this10.onAdError(adError);
}
}).catch(function () {});
}
@ -9614,23 +9602,23 @@ typeof navigator === "object" && (function (global, factory) {
}, {
key: "loadAds",
value: function loadAds() {
var _this10 = this;
var _this11 = this;
// Tell our adsManager to go bye bye
this.managerPromise.then(function () {
// Destroy our adsManager
if (_this10.manager) {
_this10.manager.destroy();
if (_this11.manager) {
_this11.manager.destroy();
} // Re-set our adsManager promises
_this10.managerPromise = new Promise(function (resolve) {
_this10.on('loaded', resolve);
_this11.managerPromise = new Promise(function (resolve) {
_this11.on('loaded', resolve);
_this10.player.debug.log(_this10.manager);
_this11.player.debug.log(_this11.manager);
}); // Now request some new advertisements
_this10.requestAds();
_this11.requestAds();
}).catch(function () {});
}
/**
@ -9641,7 +9629,7 @@ typeof navigator === "object" && (function (global, factory) {
}, {
key: "trigger",
value: function trigger(event) {
var _this11 = this;
var _this12 = this;
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
@ -9652,7 +9640,7 @@ typeof navigator === "object" && (function (global, factory) {
if (is$1.array(handlers)) {
handlers.forEach(function (handler) {
if (is$1.function(handler)) {
handler.apply(_this11, args);
handler.apply(_this12, args);
}
});
}
@ -9686,13 +9674,13 @@ typeof navigator === "object" && (function (global, factory) {
}, {
key: "startSafetyTimer",
value: function startSafetyTimer(time, from) {
var _this12 = this;
var _this13 = this;
this.player.debug.log("Safety timer invoked from: ".concat(from));
this.safetyTimer = setTimeout(function () {
_this12.cancel();
_this13.cancel();
_this12.clearSafetyTimer('startSafetyTimer()');
_this13.clearSafetyTimer('startSafetyTimer()');
}, time);
}
/**

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -568,7 +568,7 @@ if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
});
var _core = createCommonjsModule(function (module) {
var core = module.exports = { version: '2.6.3' };
var core = module.exports = { version: '2.6.4' };
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
});
var _core_1 = _core.version;
@ -664,14 +664,31 @@ var _uid = function (key) {
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
};
var _library = false;
var _shared = createCommonjsModule(function (module) {
var SHARED = '__core-js_shared__';
var store = _global[SHARED] || (_global[SHARED] = {});
(module.exports = function (key, value) {
return store[key] || (store[key] = value !== undefined ? value : {});
})('versions', []).push({
version: _core.version,
mode: 'global',
copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
});
});
var _functionToString = _shared('native-function-to-string', Function.toString);
var _redefine = createCommonjsModule(function (module) {
var SRC = _uid('src');
var TO_STRING = 'toString';
var $toString = Function[TO_STRING];
var TPL = ('' + $toString).split(TO_STRING);
var TPL = ('' + _functionToString).split(TO_STRING);
_core.inspectSource = function (it) {
return $toString.call(it);
return _functionToString.call(it);
};
(module.exports = function (O, key, val, safe) {
@ -691,7 +708,7 @@ _core.inspectSource = function (it) {
}
// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
})(Function.prototype, TO_STRING, function toString() {
return typeof this == 'function' && this[SRC] || $toString.call(this);
return typeof this == 'function' && this[SRC] || _functionToString.call(this);
});
});
@ -761,21 +778,6 @@ var _iterCall = function (iterator, fn, value, entries) {
var _iterators = {};
var _library = false;
var _shared = createCommonjsModule(function (module) {
var SHARED = '__core-js_shared__';
var store = _global[SHARED] || (_global[SHARED] = {});
(module.exports = function (key, value) {
return store[key] || (store[key] = value !== undefined ? value : {});
})('versions', []).push({
version: _core.version,
mode: 'global',
copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
});
});
var _wks = createCommonjsModule(function (module) {
var store = _shared('wks');
@ -2118,6 +2120,7 @@ var _collection = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
};
var es6_weakMap = createCommonjsModule(function (module) {
var each = _arrayMethods(0);
@ -2125,12 +2128,12 @@ var each = _arrayMethods(0);
var NATIVE_WEAK_MAP = _validateCollection;
var IS_IE11 = !_global.ActiveXObject && 'ActiveXObject' in _global;
var WEAK_MAP = 'WeakMap';
var getWeak = _meta.getWeak;
var isExtensible = Object.isExtensible;
var uncaughtFrozenStore = _collectionWeak.ufstore;
var tmp = {};
var InternalMap;
var wrapper = function (get) {
@ -2158,7 +2161,7 @@ var methods = {
var $WeakMap = module.exports = _collection(WEAK_MAP, wrapper, methods, _collectionWeak, true, true);
// IE11 WeakMap frozen keys fix
if (_fails(function () { return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7; })) {
if (NATIVE_WEAK_MAP && IS_IE11) {
InternalMap = _collectionWeak.getConstructor(wrapper, WEAK_MAP);
_objectAssign(InternalMap.prototype, methods);
_meta.NEED = true;
@ -3722,28 +3725,6 @@ var support = {
ui: ui
};
},
// Detect support for autoplay
/* autoplay: (() => {
const video = document.createElement('video');
video.src = 'https://cdn.plyr.io/static/blank.mp4';
const promise = video.play();
if (is.promise(promise)) {
console.warn('PROMISE', promise);
promise
.then(() => {
console.warn('supported');
return true;
})
.catch(() => {
console.warn('not supported');
return false;
});
} else {
console.warn('supported - no promise');
return true;
}
})(), */
// Picture-in-picture support
// Safari & Chrome only currently
pip: function () {
@ -9317,25 +9298,7 @@ function () {
this.manager = event.getAdsManager(this.player, settings); // Get the cue points for any mid-rolls by filtering out the pre- and post-roll
this.cuePoints = this.manager.getCuePoints(); // Add advertisement cue's within the time line if available
if (!is$1.empty(this.cuePoints)) {
this.cuePoints.forEach(function (cuePoint) {
if (cuePoint !== 0 && cuePoint !== -1 && cuePoint < _this6.player.duration) {
var seekElement = _this6.player.elements.progress;
if (is$1.element(seekElement)) {
var cuePercentage = 100 / _this6.player.duration * cuePoint;
var cue = createElement('span', {
class: _this6.player.config.classNames.cues
});
cue.style.left = "".concat(cuePercentage.toString(), "%");
seekElement.appendChild(cue);
}
}
});
} // Set volume to match player
this.cuePoints = this.manager.getCuePoints(); // Set volume to match player
this.manager.setVolume(this.player.volume); // Add listeners to the required events
// Advertisement error events
@ -9352,6 +9315,29 @@ function () {
this.trigger('loaded');
}
}, {
key: "addCuePoints",
value: function addCuePoints() {
var _this7 = this;
// Add advertisement cue's within the time line if available
if (!is$1.empty(this.cuePoints)) {
this.cuePoints.forEach(function (cuePoint) {
if (cuePoint !== 0 && cuePoint !== -1 && cuePoint < _this7.player.duration) {
var seekElement = _this7.player.elements.progress;
if (is$1.element(seekElement)) {
var cuePercentage = 100 / _this7.player.duration * cuePoint;
var cue = createElement('span', {
class: _this7.player.config.classNames.cues
});
cue.style.left = "".concat(cuePercentage.toString(), "%");
seekElement.appendChild(cue);
}
}
});
}
}
/**
* This is where all the event handling takes place. Retrieve the ad from the event. Some
* events (e.g. ALL_ADS_COMPLETED) don't have the ad object associated
@ -9362,7 +9348,7 @@ function () {
}, {
key: "onAdEvent",
value: function onAdEvent(event) {
var _this7 = this;
var _this8 = this;
var container = this.player.elements.container; // Retrieve the ad from the event. Some events (e.g. ALL_ADS_COMPLETED)
// don't have ad object associated
@ -9372,7 +9358,7 @@ function () {
var dispatchEvent = function dispatchEvent(type) {
var event = "ads".concat(type.replace(/_/g, '').toLowerCase());
triggerEvent.call(_this7.player, _this7.player.media, event);
triggerEvent.call(_this8.player, _this8.player.media, event);
};
switch (event.type) {
@ -9481,37 +9467,39 @@ function () {
}, {
key: "listeners",
value: function listeners() {
var _this8 = this;
var _this9 = this;
var container = this.player.elements.container;
var time; // Add listeners to the required events
var time;
this.player.on('canplay', function () {
_this9.addCuePoints();
});
this.player.on('ended', function () {
_this8.loader.contentComplete();
_this9.loader.contentComplete();
});
this.player.on('timeupdate', function () {
time = _this8.player.currentTime;
time = _this9.player.currentTime;
});
this.player.on('seeked', function () {
var seekedTime = _this8.player.currentTime;
var seekedTime = _this9.player.currentTime;
if (is$1.empty(_this8.cuePoints)) {
if (is$1.empty(_this9.cuePoints)) {
return;
}
_this8.cuePoints.forEach(function (cuePoint, index) {
_this9.cuePoints.forEach(function (cuePoint, index) {
if (time < cuePoint && cuePoint < seekedTime) {
_this8.manager.discardAdBreak();
_this9.manager.discardAdBreak();
_this8.cuePoints.splice(index, 1);
_this9.cuePoints.splice(index, 1);
}
});
}); // Listen to the resizing of the window. And resize ad accordingly
// TODO: eventually implement ResizeObserver
window.addEventListener('resize', function () {
if (_this8.manager) {
_this8.manager.resize(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL);
if (_this9.manager) {
_this9.manager.resize(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL);
}
});
}
@ -9522,7 +9510,7 @@ function () {
}, {
key: "play",
value: function play() {
var _this9 = this;
var _this10 = this;
var container = this.player.elements.container;
@ -9533,23 +9521,23 @@ function () {
this.managerPromise.then(function () {
// Initialize the container. Must be done via a user action on mobile devices
_this9.elements.displayContainer.initialize();
_this10.elements.displayContainer.initialize();
try {
if (!_this9.initialized) {
if (!_this10.initialized) {
// Initialize the ads manager. Ad rules playlist will start at this time
_this9.manager.init(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL); // Call play to start showing the ad. Single video and overlay ads will
_this10.manager.init(container.offsetWidth, container.offsetHeight, google.ima.ViewMode.NORMAL); // Call play to start showing the ad. Single video and overlay ads will
// start at this time; the call will be ignored for ad rules
_this9.manager.start();
_this10.manager.start();
}
_this9.initialized = true;
_this10.initialized = true;
} catch (adError) {
// An error may be thrown if there was a problem with the
// VAST response
_this9.onAdError(adError);
_this10.onAdError(adError);
}
}).catch(function () {});
}
@ -9608,23 +9596,23 @@ function () {
}, {
key: "loadAds",
value: function loadAds() {
var _this10 = this;
var _this11 = this;
// Tell our adsManager to go bye bye
this.managerPromise.then(function () {
// Destroy our adsManager
if (_this10.manager) {
_this10.manager.destroy();
if (_this11.manager) {
_this11.manager.destroy();
} // Re-set our adsManager promises
_this10.managerPromise = new Promise(function (resolve) {
_this10.on('loaded', resolve);
_this11.managerPromise = new Promise(function (resolve) {
_this11.on('loaded', resolve);
_this10.player.debug.log(_this10.manager);
_this11.player.debug.log(_this11.manager);
}); // Now request some new advertisements
_this10.requestAds();
_this11.requestAds();
}).catch(function () {});
}
/**
@ -9635,7 +9623,7 @@ function () {
}, {
key: "trigger",
value: function trigger(event) {
var _this11 = this;
var _this12 = this;
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
@ -9646,7 +9634,7 @@ function () {
if (is$1.array(handlers)) {
handlers.forEach(function (handler) {
if (is$1.function(handler)) {
handler.apply(_this11, args);
handler.apply(_this12, args);
}
});
}
@ -9680,13 +9668,13 @@ function () {
}, {
key: "startSafetyTimer",
value: function startSafetyTimer(time, from) {
var _this12 = this;
var _this13 = this;
this.player.debug.log("Safety timer invoked from: ".concat(from));
this.safetyTimer = setTimeout(function () {
_this12.cancel();
_this13.cancel();
_this12.clearSafetyTimer('startSafetyTimer()');
_this13.clearSafetyTimer('startSafetyTimer()');
}, time);
}
/**

View File

@ -1,6 +1,6 @@
{
"name": "plyr",
"version": "3.5.0-beta.3",
"version": "3.5.0-beta.4",
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
"homepage": "https://plyr.io",
"author": "Sam Potts <sam@potts.es>",
@ -41,7 +41,7 @@
"babel-eslint": "^10.0.1",
"@babel/preset-env": "^7.3.1",
"del": "^3.0.0",
"eslint": "^5.12.1",
"eslint": "^5.13.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-config-prettier": "^4.0.0",
"eslint-plugin-import": "^2.16.0",
@ -79,12 +79,12 @@
"stylelint-config-recommended": "^2.1.0",
"stylelint-config-sass-guidelines": "^5.3.0",
"stylelint-order": "^2.0.0",
"stylelint-scss": "^3.5.1",
"stylelint-scss": "^3.5.3",
"stylelint-selector-bem-pattern": "^2.0.0",
"through2": "^3.0.0"
},
"dependencies": {
"core-js": "^2.6.3",
"core-js": "^2.6.4",
"custom-event-polyfill": "^1.0.6",
"loadjs": "^3.5.5",
"raven-js": "^3.27.0",

View File

@ -240,6 +240,23 @@ class Ads {
// Get the cue points for any mid-rolls by filtering out the pre- and post-roll
this.cuePoints = this.manager.getCuePoints();
// Set volume to match player
this.manager.setVolume(this.player.volume);
// Add listeners to the required events
// Advertisement error events
this.manager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR, error => this.onAdError(error));
// Advertisement regular events
Object.keys(google.ima.AdEvent.Type).forEach(type => {
this.manager.addEventListener(google.ima.AdEvent.Type[type], event => this.onAdEvent(event));
});
// Resolve our adsManager
this.trigger('loaded');
}
addCuePoints() {
// Add advertisement cue's within the time line if available
if (!is.empty(this.cuePoints)) {
this.cuePoints.forEach(cuePoint => {
@ -258,21 +275,6 @@ class Ads {
}
});
}
// Set volume to match player
this.manager.setVolume(this.player.volume);
// Add listeners to the required events
// Advertisement error events
this.manager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR, error => this.onAdError(error));
// Advertisement regular events
Object.keys(google.ima.AdEvent.Type).forEach(type => {
this.manager.addEventListener(google.ima.AdEvent.Type[type], event => this.onAdEvent(event));
});
// Resolve our adsManager
this.trigger('loaded');
}
/**
@ -412,7 +414,10 @@ class Ads {
const { container } = this.player.elements;
let time;
// Add listeners to the required events
this.player.on('canplay', () => {
this.addCuePoints();
});
this.player.on('ended', () => {
this.loader.contentComplete();
});

View File

@ -1748,11 +1748,16 @@ copy-props@^2.0.1:
each-props "^1.3.0"
is-plain-object "^2.0.1"
core-js@^2.4.0, core-js@^2.6.3:
core-js@^2.4.0:
version "2.6.3"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.3.tgz#4b70938bdffdaf64931e66e2db158f0892289c49"
integrity sha512-l00tmFFZOBHtYhN4Cz7k32VM7vTn3rE2ANjQDxdEN6zmXZ/xq1jQuutnmHvMG1ZJ7xd72+TA5YpUK8wz3rWsfQ==
core-js@^2.6.4:
version "2.6.4"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.4.tgz#b8897c062c4d769dd30a0ac5c73976c47f92ea0d"
integrity sha512-05qQ5hXShcqGkPZpXEFLIpxayZscVD2kuMBZewxiIPPEagukO4mqgPA9CWhUvFBJfy3ODdK2p9xyHh7FTU9/7A==
core-util-is@1.0.2, core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@ -2334,10 +2339,10 @@ eslint-module-utils@^2.3.0:
debug "^2.6.8"
pkg-dir "^2.0.0"
eslint-plugin-import@^2.15.0:
version "2.15.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.15.0.tgz#d8f3c28b8988ccde5df964706faa7c1e52f0602a"
integrity sha512-LEHqgR+RcnpGqYW7h9WMkPb/tP+ekKxWdQDztfTtZeV43IHF+X8lXU+1HOCcR4oXD24qRgEwNSxIweD5uNKGVg==
eslint-plugin-import@^2.16.0:
version "2.16.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.16.0.tgz#97ac3e75d0791c4fac0e15ef388510217be7f66f"
integrity sha512-z6oqWlf1x5GkHIFgrSvtmudnqM6Q60KM4KvpWi5ubonMjycLjndvd5+8VAZIsTlHC03djdgJuyKG6XO577px6A==
dependencies:
contains-path "^0.1.0"
debug "^2.6.9"
@ -2433,10 +2438,10 @@ eslint@^4.0.0:
table "4.0.2"
text-table "~0.2.0"
eslint@^5.12.1:
version "5.12.1"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.12.1.tgz#5ca9931fb9029d04e7be92b03ce3b58edfac7e3b"
integrity sha512-54NV+JkTpTu0d8+UYSA8mMKAG4XAsaOrozA9rCW7tgneg1mevcL7wIotPC+fZ0SkWwdhNqoXoxnQCTBp7UvTsg==
eslint@^5.13.0:
version "5.13.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.13.0.tgz#ce71cc529c450eed9504530939aa97527861ede9"
integrity sha512-nqD5WQMisciZC5EHZowejLKQjWGuFS5c70fxqSKlnDME+oz9zmE8KTlX+lHSg+/5wsC/kf9Q9eMkC8qS3oM2fg==
dependencies:
"@babel/code-frame" "^7.0.0"
ajv "^6.5.3"
@ -2467,7 +2472,6 @@ eslint@^5.12.1:
natural-compare "^1.4.0"
optionator "^0.8.2"
path-is-inside "^1.0.2"
pluralize "^7.0.0"
progress "^2.0.0"
regexpp "^2.0.1"
semver "^5.5.1"
@ -7451,7 +7455,7 @@ stylelint-order@>=1.0.0, stylelint-order@^2.0.0:
postcss "^7.0.2"
postcss-sorting "^4.0.1"
stylelint-scss@^3.4.0, stylelint-scss@^3.5.1:
stylelint-scss@^3.4.0:
version "3.5.1"
resolved "https://registry.yarnpkg.com/stylelint-scss/-/stylelint-scss-3.5.1.tgz#3759dbae8da4b03d8a9f60f5b8c098f23961db43"
integrity sha512-XNWKTU1a2EUNWdauxHPTJlGNNQzIbg48OTTIdBs5xTXxpbYAGtX/J+jBqMPjxfdySXijc/mexubuZ+ZinUGGgw==
@ -7462,6 +7466,17 @@ stylelint-scss@^3.4.0, stylelint-scss@^3.5.1:
postcss-selector-parser "^5.0.0"
postcss-value-parser "^3.3.1"
stylelint-scss@^3.5.3:
version "3.5.3"
resolved "https://registry.yarnpkg.com/stylelint-scss/-/stylelint-scss-3.5.3.tgz#e158b3061eeec26d7f6088f346998a797432f3c8"
integrity sha512-QESQUOY1ldU5tlJTTM3Megz/QtJ39S58ByjZ7dZobGDq9qMjy5jbC7PDUasrv/T7pB1UbpPojpxX9K1OR7IPEg==
dependencies:
lodash "^4.17.11"
postcss-media-query-parser "^0.2.3"
postcss-resolve-nested-selector "^0.1.1"
postcss-selector-parser "^5.0.0"
postcss-value-parser "^3.3.1"
stylelint-selector-bem-pattern@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/stylelint-selector-bem-pattern/-/stylelint-selector-bem-pattern-2.0.0.tgz#9a6130c9c90963b30e925c917079d6c8fed73f45"