Removes playerPaused variable and just use player to get its state.

This commit is contained in:
damencho 2016-04-26 10:22:12 +03:00
parent 3a9d743d47
commit 2442f0dfd3
1 changed files with 4 additions and 5 deletions

View File

@ -155,7 +155,6 @@ export default class SharedVideoManager {
window.onPlayerStateChange = function(event) { window.onPlayerStateChange = function(event) {
if (event.data == YT.PlayerState.PLAYING) { if (event.data == YT.PlayerState.PLAYING) {
self.playerPaused = false;
self.player = event.target; self.player = event.target;
@ -164,14 +163,13 @@ export default class SharedVideoManager {
self.processAttributes( self.processAttributes(
self.player, self.player,
self.initialAttributes, self.initialAttributes,
self.playerPaused); false);
self.initialAttributes = null; self.initialAttributes = null;
} }
self.smartMute(); self.smartMute();
self.updateCheck(); self.updateCheck();
} else if (event.data == YT.PlayerState.PAUSED) { } else if (event.data == YT.PlayerState.PAUSED) {
self.playerPaused = true;
self.smartUnmute(); self.smartUnmute();
self.updateCheck(true); self.updateCheck(true);
} }
@ -372,7 +370,8 @@ export default class SharedVideoManager {
if(!this.player) if(!this.player)
this.initialAttributes = attributes; this.initialAttributes = attributes;
else { else {
this.processAttributes(this.player, attributes, this.playerPaused); this.processAttributes(this.player, attributes,
(this.player.getPlayerState() === YT.PlayerState.PAUSED));
} }
} }
@ -446,7 +445,7 @@ export default class SharedVideoManager {
if (muted) { if (muted) {
this.mutedWithUserInteraction = userInteraction; this.mutedWithUserInteraction = userInteraction;
} }
else if (!this.playerPaused) { else if (this.player.getPlayerState() !== YT.PlayerState.PAUSED) {
this.mutePlayer(true); this.mutePlayer(true);
} }
} }