diff options
author | Sam Potts <sam@potts.es> | 2018-05-08 22:22:43 +1000 |
---|---|---|
committer | Sam Potts <sam@potts.es> | 2018-05-08 22:22:43 +1000 |
commit | 34401de3d03e61eb7d1a04f6f0b7599e7ce9cd93 (patch) | |
tree | f8f46e1f38bdfb28d8ccc146a4d014ca1ca05a31 /src/js/plugins/ads.js | |
parent | 403df36af6813acf762e2b85bae6b1584b781c59 (diff) | |
parent | f687b81b70a73835f0190fbfa17a0fbbfcd28b7a (diff) | |
download | plyr-34401de3d03e61eb7d1a04f6f0b7599e7ce9cd93.tar.lz plyr-34401de3d03e61eb7d1a04f6f0b7599e7ce9cd93.tar.xz plyr-34401de3d03e61eb7d1a04f6f0b7599e7ce9cd93.zip |
Merge branch 'master' into develop
Diffstat (limited to 'src/js/plugins/ads.js')
-rw-r--r-- | src/js/plugins/ads.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/js/plugins/ads.js b/src/js/plugins/ads.js index b9d9ac1c..0246e221 100644 --- a/src/js/plugins/ads.js +++ b/src/js/plugins/ads.js @@ -6,8 +6,8 @@ /* global google */ -import utils from '../utils'; import i18n from '../i18n'; +import utils from '../utils'; class Ads { /** @@ -18,7 +18,6 @@ class Ads { constructor(player) { this.player = player; this.publisherId = player.config.ads.publisherId; - this.enabled = player.isHTML5 && player.isVideo && player.config.ads.enabled && utils.is.string(this.publisherId) && this.publisherId.length; this.playing = false; this.initialized = false; this.elements = { @@ -44,6 +43,10 @@ class Ads { this.load(); } + get enabled() { + return this.player.isVideo && this.player.config.ads.enabled && !utils.is.empty(this.publisherId); + } + /** * Load the IMA SDK */ @@ -52,7 +55,7 @@ class Ads { // Check if the Google IMA3 SDK is loaded or load it ourselves if (!utils.is.object(window.google) || !utils.is.object(window.google.ima)) { utils - .loadScript(this.player.config.urls.googleIMA.api) + .loadScript(this.player.config.urls.googleIMA.sdk) .then(() => { this.ready(); }) @@ -160,6 +163,9 @@ class Ads { // We only overlay ads as we only support video. request.forceNonLinearFullSlot = false; + // Mute based on current state + request.setAdWillPlayMuted(!this.player.muted); + this.loader.requestAds(request); } catch (e) { this.onAdError(e); @@ -226,7 +232,7 @@ class Ads { // Get skippable state // TODO: Skip button - // this.manager.getAdSkippableState(); + // this.player.debug.warn(this.manager.getAdSkippableState()); // Set volume to match player this.manager.setVolume(this.player.volume); |