This commit is contained in:
Calvin Montgomery 2014-06-17 19:11:41 -07:00
parent 5b76d4fb8c
commit 523bdfe065

View file

@ -977,34 +977,12 @@ PlaylistModule.prototype.startPlayback = function (time) {
var media = self.current.media; var media = self.current.media;
media.reset(); media.reset();
if (media.type === "vi" && !media.meta.direct && Config.get("vimeo-workaround")) { var continuePlayback = function () {
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;
}
if (self.leader != null) { if (self.leader != null) {
media.paused = false; media.paused = false;
media.currentTime = time || 0; media.currentTime = time || 0;
self.sendChangeMedia(self.channel.users); self.sendChangeMedia(self.channel.users);
self.channel.notifyModules("onMediaChange", this.current.media); self.channel.notifyModules("onMediaChange", self.current.media);
return; return;
} }
@ -1020,7 +998,7 @@ PlaylistModule.prototype.startPlayback = function (time) {
} }
self.sendChangeMedia(self.channel.users); 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 */ /* Only start the timer if the media item is not live, i.e. has a duration */
if (media.seconds > 0) { if (media.seconds > 0) {
@ -1031,18 +1009,41 @@ PlaylistModule.prototype.startPlayback = function (time) {
} }
/* Google Docs autorefresh */ /* Google Docs autorefresh */
if (this._gdRefreshTimer) { if (self._gdRefreshTimer) {
clearInterval(this._gdRefreshTimer); clearInterval(self._gdRefreshTimer);
this._gdRefreshTimer = false; self._gdRefreshTimer = false;
} }
if (media.type === "gd") { 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) { if (media.meta.expiration && media.meta.expiration < Date.now() + 3600000) {
var self = this; setTimeout(self.refreshGoogleDocs.bind(self), media.meta.expiration - Date.now());
setTimeout(this.refreshGoogleDocs.bind(this), 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"); const UPDATE_INTERVAL = Config.get("playlist.update-interval");