Still working on stuff

This commit is contained in:
calzoneman 2013-06-30 15:33:38 -04:00
parent 9a3563ca45
commit 8292a548fd
3 changed files with 28 additions and 21 deletions

View File

@ -1262,15 +1262,9 @@ Channel.prototype.trySetTemp = function(user, data) {
Channel.prototype.dequeue = function(uid, removeonly) { Channel.prototype.dequeue = function(uid, removeonly) {
if(!this.playlist.remove(uid)) if(!this.playlist.remove(uid, true))
return; return;
this.sendAll("delete", {
uid: uid
});
this.broadcastPlaylistMeta(); this.broadcastPlaylistMeta();
if(removeonly)
return;
} }
Channel.prototype.tryDequeue = function(user, data) { Channel.prototype.tryDequeue = function(user, data) {
@ -1392,16 +1386,15 @@ Channel.prototype.tryUpdate = function(user, data) {
return; return;
} }
if(data == null || if(typeof data.id !== "string" || typeof data.currentTime !== "number")
data.id == undefined || data.currentTime == undefined) {
return; return;
}
if(this.playlist.current === null) { if(this.playlist.current === null) {
return; return;
} }
if(isLive(this.playlist.current.media.type) && this.playlist.current.media.type != "jw") { if(isLive(this.playlist.current.media.type)
&& this.playlist.current.media.type != "jw") {
return; return;
} }

View File

@ -28,16 +28,24 @@ function Playlist(chan) {
this.leading = true; this.leading = true;
this.callbacks = { this.callbacks = {
"changeMedia": [], "changeMedia": [],
"mediaUpdate": [] "mediaUpdate": [],
"remove": [],
}; };
if(chan) { if(chan) {
var pl = this;
this.on("mediaUpdate", function(m) { this.on("mediaUpdate", function(m) {
chan.sendAll("mediaUpdate", m.timeupdate()); chan.sendAll("mediaUpdate", m.timeupdate());
}); });
this.on("changeMedia", function(m) { this.on("changeMedia", function(m) {
chan.sendAll("setCurrent", pl.current.uid);
chan.sendAll("changeMedia", m.fullupdate()); chan.sendAll("changeMedia", m.fullupdate());
}); });
this.on("remove", function(item) {
chan.sendAll("delete", {
uid: item.uid
});
});
} }
} }
@ -141,6 +149,8 @@ Playlist.prototype.remove = function(uid, next) {
if(item.next) if(item.next)
item.next.prev = item.prev; item.next.prev = item.prev;
this.on("remove")(item);
if(this.current == item && next) if(this.current == item && next)
this._next(); this._next();
@ -218,6 +228,7 @@ Playlist.prototype.clear = function() {
Playlist.prototype.lead = function(lead) { Playlist.prototype.lead = function(lead) {
this.leading = lead; this.leading = lead;
var pl = this;
if(!this.leading && this._leadInterval) { if(!this.leading && this._leadInterval) {
clearInterval(this._leadInterval); clearInterval(this._leadInterval);
this._leadInterval = false; this._leadInterval = false;
@ -234,6 +245,8 @@ Playlist.prototype.startPlayback = function() {
this.current.media.currentTime = -2; this.current.media.currentTime = -2;
var pl = this; var pl = this;
setTimeout(function() { setTimeout(function() {
if(!pl.current)
return;
pl.current.media.paused = false; pl.current.media.paused = false;
pl.on("mediaUpdate")(pl.current.media); pl.on("mediaUpdate")(pl.current.media);
}, 2000); }, 2000);

View File

@ -718,21 +718,22 @@ Callbacks = {
playlistMove(data.from, data.after); playlistMove(data.from, data.after);
}, },
changeMedia: function(data) { setCurrent: function(uid) {
PL_CURRENT = data.uid; PL_CURRENT = uid;
var qli = $("#queue li"); var qli = $("#queue li");
$("#queue li").removeClass("queue_active"); qli.removeClass("queue_active");
var li = $(".pluid-" + data.uid); var li = $(".pluid-" + uid);
if(li.length == 0) { if(li.length == 0) {
console.log("couldn't find uid" + data.uid); return false;
} }
// TODO send separate frame for highlight
//li.addClass("queue_active"); li.addClass("queue_active");
$("#queue").scrollTop(0); $("#queue").scrollTop(0);
//var scroll = li.position().top - $("#queue").position().top; var scroll = li.position().top - $("#queue").position().top;
//$("#queue").scrollTop(scroll); $("#queue").scrollTop(scroll);
},
changeMedia: function(data) {
if(CHANNEL.opts.allow_voteskip) if(CHANNEL.opts.allow_voteskip)
$("#voteskip").attr("disabled", false); $("#voteskip").attr("disabled", false);