Skip to content

Commit

Permalink
fix: Wait until PlayerWrapper ready before invoking SdkImpl.initAdObj…
Browse files Browse the repository at this point in the history
…ects (#638)
  • Loading branch information
gawhyte authored and shawnbuso committed Jun 6, 2018
1 parent 9701135 commit fd409d6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
8 changes: 8 additions & 0 deletions src/controller.js
Expand Up @@ -482,6 +482,14 @@ Controller.prototype.onPlayerReadyForPreroll = function() {
};


/**
* Called when the player is ready.
*/
Controller.prototype.onPlayerReady = function() {
this.sdkImpl.onPlayerReady();
};


/**
* Called when the player enters fullscreen.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/player-wrapper.js
Expand Up @@ -278,6 +278,8 @@ PlayerWrapper.prototype.onPlayerReady = function() {
this.onVolumeChange();
this.vjsPlayer.on('fullscreenchange', this.onFullscreenChange.bind(this));
this.vjsPlayer.on('volumechange', this.onVolumeChange.bind(this));

this.controller.onPlayerReady();
};


Expand Down
16 changes: 9 additions & 7 deletions src/sdk-impl.js
Expand Up @@ -142,13 +142,6 @@ const SdkImpl = function(controller) {
google.ima.settings.setDisableCustomPlaybackForIOS10Plus(
this.controller.getSettings().disableCustomPlaybackForIOS10Plus);
}

this.initAdObjects();

if (this.controller.getSettings().adTagUrl ||
this.controller.getSettings().adsResponse) {
this.requestAds();
}
};


Expand Down Expand Up @@ -533,6 +526,15 @@ SdkImpl.prototype.onPlayerReadyForPreroll = function() {
}
};

SdkImpl.prototype.onPlayerReady = function() {
this.initAdObjects();

if (this.controller.getSettings().adTagUrl ||
this.controller.getSettings().adsResponse) {
this.requestAds();
}
};


SdkImpl.prototype.onPlayerEnterFullscreen = function() {
if (this.adsManager) {
Expand Down

0 comments on commit fd409d6

Please sign in to comment.