diff options
author | Sam Potts <me@sampotts.me> | 2018-01-23 10:31:21 +1100 |
---|---|---|
committer | Sam Potts <me@sampotts.me> | 2018-01-23 10:31:21 +1100 |
commit | cc128e60888468a90dd73c90f05fc7ddbf104551 (patch) | |
tree | 7f85402d4fef3d5d6394e8c0a30291963b03323c /src/js/plugins/ads.js | |
parent | 3c8acb4e9e76d1b0ab59c86c18d3ef16efbbfe6f (diff) | |
download | plyr-cc128e60888468a90dd73c90f05fc7ddbf104551.tar.lz plyr-cc128e60888468a90dd73c90f05fc7ddbf104551.tar.xz plyr-cc128e60888468a90dd73c90f05fc7ddbf104551.zip |
Renamed property, UI tweak
Diffstat (limited to 'src/js/plugins/ads.js')
-rw-r--r-- | src/js/plugins/ads.js | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/js/plugins/ads.js b/src/js/plugins/ads.js index e7940d18..5c828141 100644 --- a/src/js/plugins/ads.js +++ b/src/js/plugins/ads.js @@ -18,7 +18,7 @@ class Ads { this.player = player; this.playing = false; this.initialized = false; - this.enabled = utils.is.url(player.config.ads.tagUrl); + this.enabled = utils.is.url(player.config.ads.tag); // Check if a tag URL is provided. if (!this.enabled) { @@ -122,7 +122,7 @@ class Ads { // Request video ads const request = new google.ima.AdsRequest(); - request.adTagUrl = this.player.config.ads.tagUrl; + request.adTagUrl = this.player.config.ads.tag; // Specify the linear and nonlinear slot sizes. This helps the SDK // to select the correct creative if multiple are returned @@ -150,15 +150,15 @@ class Ads { if (!start) { window.clearInterval(this.countdownTimer); this.elements.container.removeAttribute('data-badge-text'); + return; } const update = () => { const time = utils.formatTime(this.manager.getRemainingTime()); - const text = this.player.config.i18n.adCountdown.replace('{countdown}', time); - this.elements.container.setAttribute('data-badge-text', text); + this.elements.container.setAttribute('data-badge-text', time); }; - this.countdownTimer = window.setInterval(update, 500); + this.countdownTimer = window.setInterval(update, 100); } /** @@ -296,7 +296,9 @@ class Ads { // for example display a pause button and remaining time. Fired when content should // be paused. This usually happens right before an ad is about to cover the content this.handleEventListeners('CONTENT_PAUSE_REQUESTED'); + dispatchEvent('contentpause'); + this.pauseContent(); break; @@ -307,8 +309,13 @@ class Ads { // Fired when content should be resumed. This usually happens when an ad finishes // or collapses this.handleEventListeners('CONTENT_RESUME_REQUESTED'); + dispatchEvent('contentresume'); + + this.pollCountdown(); + this.resumeContent(); + break; case google.ima.AdEvent.Type.STARTED: @@ -321,9 +328,6 @@ class Ads { case google.ima.AdEvent.Type.COMPLETE: dispatchEvent('complete'); - - // End countdown - this.pollCountdown(); break; case google.ima.AdEvent.Type.IMPRESSION: |