mirror of https://github.com/calzoneman/sync.git
Fix #80
This commit is contained in:
parent
cf1546ed72
commit
3da4baba52
54
channel.js
54
channel.js
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue