From 9efebc370269487efcd708d6ebf5da021821949a Mon Sep 17 00:00:00 2001 From: damencho Date: Wed, 23 Mar 2016 22:42:17 -0500 Subject: [PATCH] Fixes early initial pause event, may lead to player keep buffering without starting. --- modules/UI/shared_video/SharedVideo.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/UI/shared_video/SharedVideo.js b/modules/UI/shared_video/SharedVideo.js index e65f7d12a..10e99aadc 100644 --- a/modules/UI/shared_video/SharedVideo.js +++ b/modules/UI/shared_video/SharedVideo.js @@ -96,9 +96,19 @@ export default class SharedVideoManager { }); }; + // whether we should pause the player as initial status + // sometimes if we try to pause the player before it starts playing + // we can end up with player in buffering mode + this.initialPause = false; window.onPlayerStateChange = function(event) { if (event.data == YT.PlayerState.PLAYING) { self.playerPaused = false; + + // check for initial pause + if(self.initialPause) { + self.initialPause = false; + self.player.pauseVideo(); + } self.updateCheck(); } else if (event.data == YT.PlayerState.PAUSED) { self.playerPaused = true; @@ -134,7 +144,7 @@ export default class SharedVideoManager { // set initial state of the player if there is enough information if(attributes.state === 'pause') - player.pauseVideo(); + self.initialPause = true; else if(attributes.time > 0) { console.log("Player seekTo:", attributes.time); player.seekTo(attributes.time);