From 7c02803ef978c387a8c1da4a765fd52801e846f4 Mon Sep 17 00:00:00 2001 From: damencho Date: Sun, 27 Mar 2016 15:32:45 -0500 Subject: [PATCH 1/2] Seeks in video when we start in paused state. --- modules/UI/shared_video/SharedVideo.js | 36 +++++++++++++++++--------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/modules/UI/shared_video/SharedVideo.js b/modules/UI/shared_video/SharedVideo.js index 0ced143a4..9a8e5a857 100644 --- a/modules/UI/shared_video/SharedVideo.js +++ b/modules/UI/shared_video/SharedVideo.js @@ -177,17 +177,7 @@ export default class SharedVideoManager { if (attributes.state == 'playing') { - // check received time and current time - let currentPosition = player.getCurrentTime(); - let diff = Math.abs(attributes.time - currentPosition); - - // if we drift more than the interval for checking - // sync, the interval is in milliseconds - if(diff > updateInterval/1000) { - console.info("DDD Player seekTo:", attributes.time, - " current time is:", currentPosition, " diff:", diff); - player.seekTo(attributes.time); - } + this.processTime(player, attributes); // lets check the volume if (attributes.volume !== undefined && @@ -202,6 +192,28 @@ export default class SharedVideoManager { } else if (attributes.state == 'pause') { // if its not paused, pause it player.pauseVideo(); + + this.processTime(player, attributes); + } + } + + /** + * Check for time in attributes and if needed seek in current player + * @param player the player to operate over + * @param attributes the attributes with the player state we want + */ + processTime (player, attributes) + { + // check received time and current time + let currentPosition = player.getCurrentTime(); + let diff = Math.abs(attributes.time - currentPosition); + + // if we drift more than the interval for checking + // sync, the interval is in milliseconds + if(diff > updateInterval/1000) { + console.info("Player seekTo:", attributes.time, + " current time is:", currentPosition, " diff:", diff); + player.seekTo(attributes.time); } } @@ -219,7 +231,7 @@ export default class SharedVideoManager { // if its paused and haven't been pause - send paused if (state === YT.PlayerState.PAUSED && sendPauseEvent) { this.emitter.emit(UIEvents.UPDATE_SHARED_VIDEO, - this.url, 'pause'); + this.url, 'pause', this.player.getCurrentTime()); } // if its playing and it was paused - send update with time // if its playing and was playing just send update with time From 9632bd531c12b0f8d90c745cd8c54bedd8e0a7b0 Mon Sep 17 00:00:00 2001 From: damencho Date: Mon, 28 Mar 2016 13:33:02 -0500 Subject: [PATCH 2/2] Does not accumulate multiple pause events in commands. --- conference.js | 1 + 1 file changed, 1 insertion(+) diff --git a/conference.js b/conference.js index 3d5b27050..0db8e7a90 100644 --- a/conference.js +++ b/conference.js @@ -1101,6 +1101,7 @@ export default { else { // in case of paused, in order to allow late users to join // paused + room.removeCommand(Commands.SHARED_VIDEO); room.sendCommand(Commands.SHARED_VIDEO, { value: url, attributes: {