mirror of https://github.com/calzoneman/sync.git
Factor out resumeAutolead()
This commit is contained in:
parent
217ed115a3
commit
8d39daf942
|
@ -234,20 +234,29 @@ PlaylistModule.prototype.onUserPostJoin = function (user) {
|
||||||
user.socket.typecheckedOn("queuePlaylist", TYPE_QUEUE_PLAYLIST, this.handleQueuePlaylist.bind(this, user));
|
user.socket.typecheckedOn("queuePlaylist", TYPE_QUEUE_PLAYLIST, this.handleQueuePlaylist.bind(this, user));
|
||||||
};
|
};
|
||||||
|
|
||||||
PlaylistModule.prototype.onUserPart = function (user) {
|
PlaylistModule.prototype.resumeAutolead = function () {
|
||||||
if (this.leader === user) {
|
|
||||||
this.leader = null;
|
|
||||||
this.channel.broadcastAll("setLeader", "");
|
this.channel.broadcastAll("setLeader", "");
|
||||||
|
|
||||||
this.channel.logger.log("[playlist] Resuming autolead");
|
this.channel.logger.log("[playlist] Resuming autolead");
|
||||||
if (this.current !== null) {
|
if (this.current !== null) {
|
||||||
|
// Ensure the video is unpaused before resuming autolead.
|
||||||
|
// In the past, people have reported stuck playlists because
|
||||||
|
// they assigned leader, paused, then removed leader.
|
||||||
this.current.media.paused = false;
|
this.current.media.paused = false;
|
||||||
if (!this._leadInterval) {
|
this.sendMediaUpdate(this.channel.users);
|
||||||
|
|
||||||
|
if (!this._leadInterval && this.current.media.seconds > 0) {
|
||||||
this._lastUpdate = Date.now();
|
this._lastUpdate = Date.now();
|
||||||
this._leadInterval = setInterval(this._leadLoop.bind(this), 1000);
|
this._leadInterval = setInterval(this._leadLoop.bind(this), 1000);
|
||||||
this._leadLoop();
|
this._leadLoop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
PlaylistModule.prototype.onUserPart = function (user) {
|
||||||
|
if (this.leader === user) {
|
||||||
|
this.leader = null;
|
||||||
|
this.resumeAutolead();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -736,22 +745,7 @@ PlaylistModule.prototype.handleAssignLeader = function (user, data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!name) {
|
if (!name) {
|
||||||
this.channel.broadcastAll("setLeader", "");
|
this.resumeAutolead();
|
||||||
|
|
||||||
this.channel.logger.log("[playlist] Resuming autolead");
|
|
||||||
if (this.current !== null) {
|
|
||||||
// Ensure the video is unpaused before resuming autolead.
|
|
||||||
// In the past, people have reported stuck playlists because
|
|
||||||
// they assigned leader, paused, then removed leader.
|
|
||||||
this.current.media.paused = false;
|
|
||||||
this.sendMediaUpdate(this.channel.users);
|
|
||||||
|
|
||||||
if (!this._leadInterval && this.current.media.seconds > 0) {
|
|
||||||
this._lastUpdate = Date.now();
|
|
||||||
this._leadInterval = setInterval(this._leadLoop.bind(this), 1000);
|
|
||||||
this._leadLoop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue