mirror of https://github.com/calzoneman/sync.git
Handle #377
This commit is contained in:
parent
5b76d4fb8c
commit
523bdfe065
|
@ -977,34 +977,12 @@ PlaylistModule.prototype.startPlayback = function (time) {
|
|||
var media = self.current.media;
|
||||
media.reset();
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (media.type === "gd" && isExpired(media) && !media.meta.failed) {
|
||||
self.channel.activeLock.lock();
|
||||
this.refreshGoogleDocs(function () {
|
||||
self.channel.activeLock.release();
|
||||
if (self.current && self.current.media === media) {
|
||||
self.startPlayback(time);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var continuePlayback = function () {
|
||||
if (self.leader != null) {
|
||||
media.paused = false;
|
||||
media.currentTime = time || 0;
|
||||
self.sendChangeMedia(self.channel.users);
|
||||
self.channel.notifyModules("onMediaChange", this.current.media);
|
||||
self.channel.notifyModules("onMediaChange", self.current.media);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1020,7 +998,7 @@ PlaylistModule.prototype.startPlayback = function (time) {
|
|||
}
|
||||
|
||||
self.sendChangeMedia(self.channel.users);
|
||||
self.channel.notifyModules("onMediaChange", this.current.media);
|
||||
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) {
|
||||
|
@ -1031,18 +1009,41 @@ PlaylistModule.prototype.startPlayback = function (time) {
|
|||
}
|
||||
|
||||
/* Google Docs autorefresh */
|
||||
if (this._gdRefreshTimer) {
|
||||
clearInterval(this._gdRefreshTimer);
|
||||
this._gdRefreshTimer = false;
|
||||
if (self._gdRefreshTimer) {
|
||||
clearInterval(self._gdRefreshTimer);
|
||||
self._gdRefreshTimer = false;
|
||||
}
|
||||
|
||||
if (media.type === "gd") {
|
||||
this._gdRefreshTimer = setInterval(this.refreshGoogleDocs.bind(this), 3600000);
|
||||
self._gdRefreshTimer = setInterval(self.refreshGoogleDocs.bind(self), 3600000);
|
||||
if (media.meta.expiration && media.meta.expiration < Date.now() + 3600000) {
|
||||
var self = this;
|
||||
setTimeout(this.refreshGoogleDocs.bind(this), media.meta.expiration - Date.now());
|
||||
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;
|
||||
continuePlayback();
|
||||
}
|
||||
});
|
||||
return;
|
||||
} else if (media.type === "gd" && isExpired(media) && !media.meta.failed) {
|
||||
self.channel.activeLock.lock();
|
||||
self.refreshGoogleDocs(function () {
|
||||
self.channel.activeLock.release();
|
||||
if (self.current && self.current.media === media) {
|
||||
continuePlayback();
|
||||
}
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
continuePlayback();
|
||||
}
|
||||
}
|
||||
|
||||
const UPDATE_INTERVAL = Config.get("playlist.update-interval");
|
||||
|
|
Loading…
Reference in New Issue