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) {
if(!this.playlist.remove(uid))
if(!this.playlist.remove(uid, true))
return;
this.sendAll("delete", {
uid: uid
});
this.broadcastPlaylistMeta();
if(removeonly)
return;
}
Channel.prototype.tryDequeue = function(user, data) {
@ -1392,16 +1386,15 @@ Channel.prototype.tryUpdate = function(user, data) {
return;
}
if(data == null ||
data.id == undefined || data.currentTime == undefined) {
if(typeof data.id !== "string" || typeof data.currentTime !== "number")
return;
}
if(this.playlist.current === null) {
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;
}

View File

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

View File

@ -718,21 +718,22 @@ Callbacks = {
playlistMove(data.from, data.after);
},
changeMedia: function(data) {
PL_CURRENT = data.uid;
setCurrent: function(uid) {
PL_CURRENT = uid;
var qli = $("#queue li");
$("#queue li").removeClass("queue_active");
var li = $(".pluid-" + data.uid);
qli.removeClass("queue_active");
var li = $(".pluid-" + uid);
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);
//var scroll = li.position().top - $("#queue").position().top;
//$("#queue").scrollTop(scroll);
var scroll = li.position().top - $("#queue").position().top;
$("#queue").scrollTop(scroll);
},
changeMedia: function(data) {
if(CHANNEL.opts.allow_voteskip)
$("#voteskip").attr("disabled", false);