mirror of https://github.com/calzoneman/sync.git
Handle #377
This commit is contained in:
parent
5b76d4fb8c
commit
523bdfe065
|
@ -977,71 +977,72 @@ PlaylistModule.prototype.startPlayback = function (time) {
|
|||
var media = self.current.media;
|
||||
media.reset();
|
||||
|
||||
var continuePlayback = function () {
|
||||
if (self.leader != null) {
|
||||
media.paused = false;
|
||||
media.currentTime = time || 0;
|
||||
self.sendChangeMedia(self.channel.users);
|
||||
self.channel.notifyModules("onMediaChange", self.current.media);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Lead-in time of 3 seconds to allow clients to buffer */
|
||||
time = time || -3;
|
||||
media.paused = time < 0;
|
||||
media.currentTime = time;
|
||||
|
||||
/* Module was already leading, stop the previous timer */
|
||||
if (self._leadInterval) {
|
||||
clearInterval(self._leadInterval);
|
||||
self._leadInterval = false;
|
||||
}
|
||||
|
||||
self.sendChangeMedia(self.channel.users);
|
||||
self.channel.notifyModules("onMediaChange", self.current.media);
|
||||
|
||||
/* Only start the timer if the media item is not live, i.e. has a duration */
|
||||
if (media.seconds > 0) {
|
||||
self._lastUpdate = Date.now();
|
||||
self._leadInterval = setInterval(function() {
|
||||
self._leadLoop();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
/* Google Docs autorefresh */
|
||||
if (self._gdRefreshTimer) {
|
||||
clearInterval(self._gdRefreshTimer);
|
||||
self._gdRefreshTimer = false;
|
||||
}
|
||||
|
||||
if (media.type === "gd") {
|
||||
self._gdRefreshTimer = setInterval(self.refreshGoogleDocs.bind(self), 3600000);
|
||||
if (media.meta.expiration && media.meta.expiration < Date.now() + 3600000) {
|
||||
setTimeout(self.refreshGoogleDocs.bind(self), media.meta.expiration - Date.now());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (media.type === "vi" && !media.meta.direct && Config.get("vimeo-workaround")) {
|
||||
self.channel.activeLock.lock();
|
||||
vimeoWorkaround(media.id, function (direct) {
|
||||
self.channel.activeLock.release();
|
||||
if (self.current && self.current.media === media) {
|
||||
self.current.media.meta.direct = direct;
|
||||
self.startPlayback(time);
|
||||
continuePlayback();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (media.type === "gd" && isExpired(media) && !media.meta.failed) {
|
||||
} else if (media.type === "gd" && isExpired(media) && !media.meta.failed) {
|
||||
self.channel.activeLock.lock();
|
||||
this.refreshGoogleDocs(function () {
|
||||
self.refreshGoogleDocs(function () {
|
||||
self.channel.activeLock.release();
|
||||
if (self.current && self.current.media === media) {
|
||||
self.startPlayback(time);
|
||||
continuePlayback();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.leader != null) {
|
||||
media.paused = false;
|
||||
media.currentTime = time || 0;
|
||||
self.sendChangeMedia(self.channel.users);
|
||||
self.channel.notifyModules("onMediaChange", this.current.media);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Lead-in time of 3 seconds to allow clients to buffer */
|
||||
time = time || -3;
|
||||
media.paused = time < 0;
|
||||
media.currentTime = time;
|
||||
|
||||
/* Module was already leading, stop the previous timer */
|
||||
if (self._leadInterval) {
|
||||
clearInterval(self._leadInterval);
|
||||
self._leadInterval = false;
|
||||
}
|
||||
|
||||
self.sendChangeMedia(self.channel.users);
|
||||
self.channel.notifyModules("onMediaChange", this.current.media);
|
||||
|
||||
/* Only start the timer if the media item is not live, i.e. has a duration */
|
||||
if (media.seconds > 0) {
|
||||
self._lastUpdate = Date.now();
|
||||
self._leadInterval = setInterval(function() {
|
||||
self._leadLoop();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
/* Google Docs autorefresh */
|
||||
if (this._gdRefreshTimer) {
|
||||
clearInterval(this._gdRefreshTimer);
|
||||
this._gdRefreshTimer = false;
|
||||
}
|
||||
|
||||
if (media.type === "gd") {
|
||||
this._gdRefreshTimer = setInterval(this.refreshGoogleDocs.bind(this), 3600000);
|
||||
if (media.meta.expiration && media.meta.expiration < Date.now() + 3600000) {
|
||||
var self = this;
|
||||
setTimeout(this.refreshGoogleDocs.bind(this), media.meta.expiration - Date.now());
|
||||
}
|
||||
} else {
|
||||
continuePlayback();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue