From ebe37ff98a1ea3fdebce6c381da5fa0099d37876 Mon Sep 17 00:00:00 2001 From: damencho Date: Thu, 31 Mar 2016 14:11:33 -0500 Subject: [PATCH] Handle on player error so we can remove the player. --- modules/UI/shared_video/SharedVideo.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/modules/UI/shared_video/SharedVideo.js b/modules/UI/shared_video/SharedVideo.js index addf0a238..26996e397 100644 --- a/modules/UI/shared_video/SharedVideo.js +++ b/modules/UI/shared_video/SharedVideo.js @@ -162,6 +162,8 @@ export default class SharedVideoManager { window.onPlayerError = function(event) { console.error("Error in the player:", event.data); + // store the error player, so we can remove it + self.errorInPlayer = event.target; }; } @@ -293,8 +295,12 @@ export default class SharedVideoManager { return; if(!this.player){ - this.initialAttributes = attributes; - return; + // if there is no error in the player till now, + // store the initial attributes + if (!this.errorInPlayer) { + this.initialAttributes = attributes; + return; + } } if(this.intervalId) { @@ -309,12 +315,19 @@ export default class SharedVideoManager { VideoLayout.removeLargeVideoContainer( SHARED_VIDEO_CONTAINER_TYPE); - this.player.destroy(); - this.player = null; + if(this.player) { + this.player.destroy(); + this.player = null; + }// + else if (this.errorInPlayer) { + this.errorInPlayer.destroy(); + this.errorInPlayer = null; + } }); this.url = null; this.isSharedVideoShown = false; + this.initialAttributes = null; } }