Fix loading google ima sdk

This commit is contained in:
ferdiemmen
2018-01-14 08:21:35 +01:00
parent 025fc1090b
commit bbdf225d7b
7 changed files with 17 additions and 128 deletions

View File

@ -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() {