Fixes pausing.

This commit is contained in:
damencho 2016-03-18 16:47:47 -05:00
parent 38275ce045
commit a1ac18a632
1 changed files with 9 additions and 5 deletions

View File

@ -101,7 +101,7 @@ export default class SharedVideoManager {
self.updateCheck(); self.updateCheck();
} else if (event.data == YT.PlayerState.PAUSED) { } else if (event.data == YT.PlayerState.PAUSED) {
self.playerPaused = true; self.playerPaused = true;
self.updateCheck(); self.updateCheck(true);
} }
}; };
@ -146,7 +146,7 @@ export default class SharedVideoManager {
/** /**
* Checks current state of the player and fire an event with the values. * Checks current state of the player and fire an event with the values.
*/ */
updateCheck() updateCheck(sendPauseEvent)
{ {
// ignore update checks if we are not the owner of the video // ignore update checks if we are not the owner of the video
if(!APP.conference.isLocalId(this.from)) if(!APP.conference.isLocalId(this.from))
@ -154,7 +154,7 @@ export default class SharedVideoManager {
let state = this.player.getPlayerState(); let state = this.player.getPlayerState();
// if its paused and haven't been pause - send paused // if its paused and haven't been pause - send paused
if (state === YT.PlayerState.PAUSED && !this.playerPaused) { if (state === YT.PlayerState.PAUSED && sendPauseEvent) {
this.emitter.emit(UIEvents.UPDATE_SHARED_VIDEO, this.emitter.emit(UIEvents.UPDATE_SHARED_VIDEO,
this.url, 'pause'); this.url, 'pause');
} }
@ -189,7 +189,12 @@ export default class SharedVideoManager {
// ocasionally we get this.player.getCurrentTime is not a function // ocasionally we get this.player.getCurrentTime is not a function
// it seems its that player hasn't really loaded // it seems its that player hasn't really loaded
if(!this.player || !this.player.getCurrentTime) if(!this.player || !this.player.getCurrentTime
|| !this.player.pauseVideo
|| !this.player.playVideo
|| !this.player.getVolume
|| !this.player.seekTo
|| !this.player.getVolume)
return; return;
// check received time and current time // check received time and current time
@ -211,7 +216,6 @@ export default class SharedVideoManager {
console.log("Player change of volume:" + attributes.volume); console.log("Player change of volume:" + attributes.volume);
} }
if(this.playerPaused) if(this.playerPaused)
this.player.playVideo(); this.player.playVideo();
} else if (attributes.state == 'pause') { } else if (attributes.state == 'pause') {