Skip to content

Commit

Permalink
Moved location of h5Player element assignment fixes #596 (#598)
Browse files Browse the repository at this point in the history
  • Loading branch information
ypavlotsky committed Apr 19, 2018
1 parent 4cba6d4 commit d1eb372
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/player-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,7 @@ const PlayerWrapper = function(player, adsPluginSettings, controller) {
/**
* Vanilla HTML5 video player underneath the video.js player.
*/
this.h5Player =
document.getElementById(
this.controller.getSettings().id).getElementsByClassName(
'vjs-tech')[0];

// Detect inline options
if (this.h5Player.hasAttribute('autoplay')) {
this.controller.setSetting('adWillAutoPlay', true);
}
this.h5Player = null;

this.vjsPlayer.one('play', this.setUpPlayerIntervals.bind(this));
this.boundContentEndedListener = this.localContentEndedListener.bind(this);
Expand Down Expand Up @@ -272,6 +264,16 @@ PlayerWrapper.prototype.onReadyForPreroll = function() {
* Called when the player fires its 'ready' event.
*/
PlayerWrapper.prototype.onPlayerReady = function() {
this.h5Player =
document.getElementById(
this.controller.getSettings().id).getElementsByClassName(
'vjs-tech')[0];

// Detect inline options
if (this.h5Player.hasAttribute('autoplay')) {
this.controller.setSetting('adWillAutoPlay', true);
}

// Sync ad volume with player volume.
this.onVolumeChange();
this.vjsPlayer.on('fullscreenchange', this.onFullscreenChange.bind(this));
Expand Down

0 comments on commit d1eb372

Please sign in to comment.