diff options
author | Sam Potts <sam@selz.com> | 2018-01-30 09:22:54 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-30 09:22:54 +1100 |
commit | bb51647fe2f6e8e0eabb3099b58cc334e23936f0 (patch) | |
tree | f0ed45d84bc0304a543bafa08216355e63e55ac8 /src/js/plugins/ads.js | |
parent | 8f7a8940f36ab85c87a3406a378d383e58ee3d60 (diff) | |
parent | 71efbe7a927a9638204129ca7a2d52c498fa7e6e (diff) | |
download | plyr-bb51647fe2f6e8e0eabb3099b58cc334e23936f0.tar.lz plyr-bb51647fe2f6e8e0eabb3099b58cc334e23936f0.tar.xz plyr-bb51647fe2f6e8e0eabb3099b58cc334e23936f0.zip |
Merge pull request #772 from sampotts/fix/ads-blocked
Fix: ads blocked and media playing before ad plays
Diffstat (limited to 'src/js/plugins/ads.js')
-rw-r--r-- | src/js/plugins/ads.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/js/plugins/ads.js b/src/js/plugins/ads.js index a71336bb..72fd49d8 100644 --- a/src/js/plugins/ads.js +++ b/src/js/plugins/ads.js @@ -35,17 +35,27 @@ class Ads { this.enabled = player.config.ads.enabled; this.playing = false; this.initialized = false; + this.blocked = false; + this.enabled = utils.is.url(player.config.ads.tag); // Check if a tag URL is provided. if (!this.enabled) { return; } - // Check if the Google IMA3 SDK is loaded + // Check if the Google IMA3 SDK is loaded or load it ourselves if (!utils.is.object(window.google)) { - utils.loadScript(player.config.urls.googleIMA.api, () => { - this.ready(); - }); + utils.loadScript( + player.config.urls.googleIMA.api, + () => { + this.ready(); + }, + () => { + // Script failed to load or is blocked + this.blocked = true; + this.player.debug.log('Ads error: Google IMA SDK failed to load'); + }, + ); } else { this.ready(); } |