From bbdf225d7b25c16d293108a9cf813c521f4d44eb Mon Sep 17 00:00:00 2001 From: ferdiemmen Date: Sun, 14 Jan 2018 08:21:35 +0100 Subject: Fix loading google ima sdk --- src/js/plugins/ads.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/js/plugins/ads.js b/src/js/plugins/ads.js index 5f19f6c7..f83948af 100644 --- a/src/js/plugins/ads.js +++ b/src/js/plugins/ads.js @@ -18,6 +18,7 @@ const getStartEvents = () => { export default class Ads { constructor(player) { + this.player = player; // Check if an adTagUrl is provided. if (!player.config.ads.adTagUrl) { @@ -26,10 +27,15 @@ export default class Ads { // Check if the Google IMA3 SDK is loaded. if (!utils.is.object(window.google)) { - utils.loadScript(player.config.urls.googleIMA.api); + utils.loadScript(player.config.urls.googleIMA.api, () => { + this.ready(this); + }); + } else { + this.ready(); } + } - this.player = player; + ready() { this.startEvents = getStartEvents(); this.adDisplayContainer = null; this.adDisplayElement = null; @@ -47,7 +53,7 @@ export default class Ads { this.setupIMA(); // Set listeners on the Plyr instance. - // this.setupListeners(); + this.setupListeners(); } setupIMA() { -- cgit v1.2.3