Plugin tweaks for ads and previews

This commit is contained in:
Sam Potts
2019-01-26 16:31:47 +11:00
parent c577eb01ce
commit c44351507f
20 changed files with 149 additions and 60 deletions

View File

@ -6528,7 +6528,8 @@ typeof navigator === "object" && (function (global, factory) {
// Register for an account here: http://vi.ai/publisher-video-monetization/?aid=plyrio
ads: {
enabled: false,
publisherId: ''
publisherId: '',
tagUrl: ''
},
// YouTube nocookies mode
noCookie: false,
@ -9083,7 +9084,7 @@ typeof navigator === "object" && (function (global, factory) {
_classCallCheck(this, Ads);
this.player = player;
this.publisherId = player.config.ads.publisherId;
this.config = player.config.ads;
this.playing = false;
this.initialized = false;
this.elements = {
@ -9150,7 +9151,7 @@ typeof navigator === "object" && (function (global, factory) {
this.listeners(); // Setup the IMA SDK
this.setupIMA();
} // Build the default tag URL
} // Build the tag URL
}, {
key: "setupIMA",
@ -9319,7 +9320,8 @@ typeof navigator === "object" && (function (global, factory) {
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
var ad = event.getAd(); // Proxy event
var ad = event.getAd();
var adData = event.getAdData(); // Proxy event
var dispatchEvent = function dispatchEvent(type) {
var event = "ads".concat(type.replace(/_/g, '').toLowerCase());
@ -9401,6 +9403,13 @@ typeof navigator === "object" && (function (global, factory) {
dispatchEvent(event.type);
break;
case google.ima.AdEvent.Type.LOG:
if (adData.adError) {
this.player.debug.warn("Non-fatal ad error: ".concat(adData.adError.getMessage()));
}
break;
default:
break;
}
@ -9433,9 +9442,8 @@ typeof navigator === "object" && (function (global, factory) {
this.player.on('ended', function () {
_this8.loader.contentComplete();
});
this.player.on('seeking', function () {
this.player.on('timeupdate', function () {
time = _this8.player.currentTime;
return time;
});
this.player.on('seeked', function () {
var seekedTime = _this8.player.currentTime;
@ -9653,11 +9661,18 @@ typeof navigator === "object" && (function (global, factory) {
}, {
key: "enabled",
get: function get() {
return this.player.isHTML5 && this.player.isVideo && this.player.config.ads.enabled && !is$1.empty(this.publisherId);
var config = this.config;
return this.player.isHTML5 && this.player.isVideo && config.enabled && (!is$1.empty(config.publisherId) || is$1.url(config.tagUrl));
}
}, {
key: "tagUrl",
get: function get() {
var config = this.config;
if (is$1.url(config.tagUrl)) {
return config.tagUrl;
}
var params = {
AV_PUBLISHERID: '58c25bb0073ef448b1087ad6',
AV_CHANNELID: '5a0458dc28a06145e4519d21',
@ -9987,12 +10002,20 @@ typeof navigator === "object" && (function (global, factory) {
this.toggleThumbContainer(true);
this.setThumbContainerSizeAndPos();
} // Find the desired thumbnail index
// TODO: Handle a video longer than the thumbs where thumbNum is null
var thumbNum = this.thumbnails[0].frames.findIndex(function (frame) {
return _this5.seekTime >= frame.startTime && _this5.seekTime <= frame.endTime;
});
var qualityIndex = 0; // Check to see if we've already downloaded higher quality versions of this image
var hasThumb = thumbNum >= 0;
var qualityIndex = 0;
this.toggleThumbContainer(hasThumb); // No matching thumb found
if (!hasThumb) {
return;
} // Check to see if we've already downloaded higher quality versions of this image
this.thumbnails.forEach(function (thumbnail, index) {
if (_this5.loadedImages.includes(thumbnail.frames[thumbNum].text)) {