Fixes early initial pause event, may lead to player keep buffering without starting.

This commit is contained in:
damencho 2016-03-23 22:42:17 -05:00
parent 32c2d912be
commit 9efebc3702
1 changed files with 11 additions and 1 deletions

View File

@ -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) { window.onPlayerStateChange = function(event) {
if (event.data == YT.PlayerState.PLAYING) { if (event.data == YT.PlayerState.PLAYING) {
self.playerPaused = false; self.playerPaused = false;
// check for initial pause
if(self.initialPause) {
self.initialPause = false;
self.player.pauseVideo();
}
self.updateCheck(); self.updateCheck();
} else if (event.data == YT.PlayerState.PAUSED) { } else if (event.data == YT.PlayerState.PAUSED) {
self.playerPaused = true; self.playerPaused = true;
@ -134,7 +144,7 @@ export default class SharedVideoManager {
// set initial state of the player if there is enough information // set initial state of the player if there is enough information
if(attributes.state === 'pause') if(attributes.state === 'pause')
player.pauseVideo(); self.initialPause = true;
else if(attributes.time > 0) { else if(attributes.time > 0) {
console.log("Player seekTo:", attributes.time); console.log("Player seekTo:", attributes.time);
player.seekTo(attributes.time); player.seekTo(attributes.time);