This commit is contained in:
calzoneman 2013-05-02 10:34:12 -05:00
parent cf1546ed72
commit 3da4baba52
1 changed files with 18 additions and 36 deletions

View File

@ -645,6 +645,18 @@ function isLive(type) {
|| type == "jw"; || type == "jw";
} }
Channel.prototype.queueAdd = function(media, idx) {
this.queue.splice(idx, 0, media);
this.sendAll("queue", {
media: media.pack(),
pos: idx
});
this.broadcastPlaylistMeta();
if(this.queue.length == 1) {
this.playNext();
}
}
Channel.prototype.enqueue = function(data, user) { Channel.prototype.enqueue = function(data, user) {
var idx = data.pos == "next" ? this.position + 1 : this.queue.length; var idx = data.pos == "next" ? this.position + 1 : this.queue.length;
@ -652,12 +664,7 @@ Channel.prototype.enqueue = function(data, user) {
if(data.id in this.library) { if(data.id in this.library) {
var media = this.library[data.id]; var media = this.library[data.id];
media.queueby = user ? user.name : ""; media.queueby = user ? user.name : "";
this.queue.splice(idx, 0, media); this.queueAdd(media, idx);
this.sendAll("queue", {
media: media.pack(),
pos: idx
});
this.broadcastPlaylistMeta();
this.logger.log("*** Queued from cache: id=" + data.id); this.logger.log("*** Queued from cache: id=" + data.id);
} }
else { else {
@ -669,12 +676,7 @@ Channel.prototype.enqueue = function(data, user) {
case "sc": case "sc":
InfoGetter.getMedia(data.id, data.type, function(media) { InfoGetter.getMedia(data.id, data.type, function(media) {
media.queueby = user ? user.name : ""; media.queueby = user ? user.name : "";
this.queue.splice(idx, 0, media); this.queueAdd(media, idx);
this.sendAll("queue", {
media: media.pack(),
pos: idx
});
this.broadcastPlaylistMeta();
this.cacheMedia(media); this.cacheMedia(media);
if(data.type == "yp") if(data.type == "yp")
idx++; idx++;
@ -683,42 +685,22 @@ Channel.prototype.enqueue = function(data, user) {
case "li": case "li":
var media = new Media(data.id, "Livestream - " + data.id, "--:--", "li"); var media = new Media(data.id, "Livestream - " + data.id, "--:--", "li");
media.queueby = user ? user.name : ""; media.queueby = user ? user.name : "";
this.queue.splice(idx, 0, media); this.queueAdd(media, idx);
this.sendAll("queue", {
media: media.pack(),
pos: idx
});
this.broadcastPlaylistMeta();
break; break;
case "tw": case "tw":
var media = new Media(data.id, "Twitch - " + data.id, "--:--", "tw"); var media = new Media(data.id, "Twitch - " + data.id, "--:--", "tw");
media.queueby = user ? user.name : ""; media.queueby = user ? user.name : "";
this.queue.splice(idx, 0, media); this.queueAdd(media, idx);
this.sendAll("queue", {
media: media.pack(),
pos: idx
});
this.broadcastPlaylistMeta();
break; break;
case "rt": case "rt":
var media = new Media(data.id, "Livestream", "--:--", "rt"); var media = new Media(data.id, "Livestream", "--:--", "rt");
media.queueby = user ? user.name : ""; media.queueby = user ? user.name : "";
this.queue.splice(idx, 0, media); this.queueAdd(media, idx);
this.sendAll("queue", {
media: media.pack(),
pos: idx
});
this.broadcastPlaylistMeta();
break; break;
case "jw": case "jw":
var media = new Media(data.id, "JWPlayer Stream - " + data.id, "--:--", "jw"); var media = new Media(data.id, "JWPlayer Stream - " + data.id, "--:--", "jw");
media.queueby = user ? user.name : ""; media.queueby = user ? user.name : "";
this.queue.splice(idx, 0, media); this.queueAdd(media, idx);
this.sendAll("queue", {
media: media.pack(),
pos: idx
});
this.broadcastPlaylistMeta();
break; break;
default: default:
break; break;