From d8cb13d833efce9357015e8b9f6cf97627c0d1d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Caldeira?= Date: Tue, 24 Jul 2018 15:35:21 +0100 Subject: [PATCH] fix: Added type to content source (#680) * Added type to content source Resolved an issue with IMA plugin and HLS plugin on post-roll completed ads: without the source type the player hangs with a format not supported error. * Update player-wrapper.js * Update player-wrapper.js --- src/player-wrapper.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/player-wrapper.js b/src/player-wrapper.js index 77fd0102..80d1f835 100644 --- a/src/player-wrapper.js +++ b/src/player-wrapper.js @@ -98,6 +98,12 @@ const PlayerWrapper = function(player, adsPluginSettings, controller) { */ this.contentSource = ''; + /** + * Stores the content source type so we can re-populate it manually after a + * post-roll. + */ + this.contentSourceType = ''; + /** * Stores data for the content playhead tracker. */ @@ -461,6 +467,7 @@ PlayerWrapper.prototype.onAdError = function(adErrorEvent) { */ PlayerWrapper.prototype.onAdBreakStart = function() { this.contentSource = this.vjsPlayer.currentSrc(); + this.contentSourceType = this.vjsPlayer.currentType(); this.vjsPlayer.off('contentended', this.boundContentEndedListener); this.vjsPlayer.ads.startLinearAdMode(); this.vjsControls.hide(); @@ -494,7 +501,12 @@ PlayerWrapper.prototype.onAdStart = function() { PlayerWrapper.prototype.onAllAdsCompleted = function() { if (this.contentComplete == true) { if (this.h5Player.src != this.contentSource) { - this.vjsPlayer.src(this.contentSource); + // Avoid setted autoplay after the post-roll + this.vjsPlayer.autoplay(false); + this.vjsPlayer.src({ + src: this.contentSource, + type: this.contentSourceType, + }); } this.controller.onContentAndAdsCompleted(); }