From 104503ee13737e311e43f2bb3f26f047dbad18ef Mon Sep 17 00:00:00 2001 From: damencho Date: Thu, 31 Mar 2016 12:14:45 -0500 Subject: [PATCH] Make sure we store initial attributes in order, so it will hold the last state we want to be in. Respects quick initial stop received. --- conference.js | 2 +- modules/UI/UI.js | 2 +- modules/UI/shared_video/SharedVideo.js | 27 ++++++++++++++------------ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/conference.js b/conference.js index dc2ba0249..bc8775e81 100644 --- a/conference.js +++ b/conference.js @@ -1110,7 +1110,7 @@ export default { Commands.SHARED_VIDEO, ({value, attributes}, id) => { if (attributes.state === 'stop') { - APP.UI.stopSharedVideo(id); + APP.UI.stopSharedVideo(id, attributes); } else if (attributes.state === 'start') { APP.UI.showSharedVideo(id, value, attributes); } else if (attributes.state === 'playing' diff --git a/modules/UI/UI.js b/modules/UI/UI.js index ce3492332..a60c276aa 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -1115,7 +1115,7 @@ UI.updateSharedVideo = function (id, url, attributes) { */ UI.stopSharedVideo = function (id, attributes) { if (sharedVideoManager) - sharedVideoManager.stopSharedVideo(id); + sharedVideoManager.stopSharedVideo(id, attributes); }; module.exports = UI; diff --git a/modules/UI/shared_video/SharedVideo.js b/modules/UI/shared_video/SharedVideo.js index 179ec6c31..addf0a238 100644 --- a/modules/UI/shared_video/SharedVideo.js +++ b/modules/UI/shared_video/SharedVideo.js @@ -44,7 +44,8 @@ export default class SharedVideoManager { if(APP.conference.isLocalId(this.from)) { showStopVideoPropmpt().then(() => - this.emitter.emit(UIEvents.UPDATE_SHARED_VIDEO, null, 'stop')); + this.emitter.emit( + UIEvents.UPDATE_SHARED_VIDEO, this.url, 'stop')); } else { messageHandler.openMessageDialog( "dialog.shareVideoTitle", @@ -84,7 +85,7 @@ export default class SharedVideoManager { // we need to operate with player after start playing // self.player will be defined once it start playing // and will process any initial attributes if any - this.initialAttributes = null; + this.initialAttributes = attributes; var self = this; if(self.isPlayerAPILoaded) @@ -157,13 +158,6 @@ export default class SharedVideoManager { self.updateCheck.bind(self), updateInterval); } - - if(self.player) - self.processAttributes( - self.player, attributes, self.playerPaused); - else { - self.initialAttributes = attributes; - } }; window.onPlayerError = function(event) { @@ -201,6 +195,8 @@ export default class SharedVideoManager { player.pauseVideo(); this.processTime(player, attributes, !playerPaused); + } else if (attributes.state == 'stop') { + this.stopSharedVideo(this.from); } } @@ -236,8 +232,10 @@ export default class SharedVideoManager { updateCheck(sendPauseEvent) { // ignore update checks if we are not the owner of the video - // or there is still no player defined - if(!APP.conference.isLocalId(this.from) || !this.player) + // or there is still no player defined or we are stopped + // (in a process of stopping) + if(!APP.conference.isLocalId(this.from) || !this.player + || !this.isSharedVideoShown) return; let state = this.player.getPlayerState(); @@ -287,13 +285,18 @@ export default class SharedVideoManager { * left and we want to remove video if the user sharing it left). * @param id the id of the sender of the command */ - stopSharedVideo (id) { + stopSharedVideo (id, attributes) { if (!this.isSharedVideoShown) return; if(this.from !== id) return; + if(!this.player){ + this.initialAttributes = attributes; + return; + } + if(this.intervalId) { clearInterval(this.intervalId); this.intervalId = null;