mirror of https://github.com/calzoneman/sync.git
JWPlayer serverside synchronization
This commit is contained in:
parent
55b6e99896
commit
0f9bfe1429
|
@ -1514,6 +1514,12 @@ Channel.prototype.handleQueue = function (user, data) {
|
||||||
var queueby = user != null ? user.name : "";
|
var queueby = user != null ? user.name : "";
|
||||||
var temp = data.temp || !this.hasPermission(user, "addnontemp");
|
var temp = data.temp || !this.hasPermission(user, "addnontemp");
|
||||||
|
|
||||||
|
// Allow override of duration for live content
|
||||||
|
var duration = undefined;
|
||||||
|
if (util.isLive(data.type) && typeof data.duration === "number") {
|
||||||
|
duration = !isNaN(data.duration) ? data.duration : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
// Throttle video adds
|
// Throttle video adds
|
||||||
var limit = {
|
var limit = {
|
||||||
burst: 3,
|
burst: 3,
|
||||||
|
@ -1543,6 +1549,7 @@ Channel.prototype.handleQueue = function (user, data) {
|
||||||
queueby: queueby,
|
queueby: queueby,
|
||||||
temp: temp,
|
temp: temp,
|
||||||
type: type,
|
type: type,
|
||||||
|
duration: duration,
|
||||||
maxlength: this.hasPermission(user, "exceedmaxlength") ? 0 : this.opts.maxlength
|
maxlength: this.hasPermission(user, "exceedmaxlength") ? 0 : this.opts.maxlength
|
||||||
}, function (err, media) {
|
}, function (err, media) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -1681,6 +1688,12 @@ Channel.prototype.addMedia = function (data, callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.duration) {
|
||||||
|
media.seconds = data.duration;
|
||||||
|
media.live = false;
|
||||||
|
} else {
|
||||||
|
media.live = true;
|
||||||
|
}
|
||||||
afterLookup(lock, false, media);
|
afterLookup(lock, false, media);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -181,7 +181,8 @@ Playlist.prototype.add = function(item, pos) {
|
||||||
self.channel.sendAll("delete", {
|
self.channel.sendAll("delete", {
|
||||||
uid: it.uid
|
uid: it.uid
|
||||||
});
|
});
|
||||||
self.channel.broadcastPlaylistMeta();
|
self.channel.updatePlaylistMeta();
|
||||||
|
self.channel.sendPlaylistMeta(self.channel.users);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pos == "append") {
|
if(pos == "append") {
|
||||||
|
@ -387,7 +388,7 @@ Playlist.prototype.startPlayback = function (time) {
|
||||||
self._leadInterval = false;
|
self._leadInterval = false;
|
||||||
}
|
}
|
||||||
self.on("changeMedia")(self.current.media);
|
self.on("changeMedia")(self.current.media);
|
||||||
if(!util.isLive(self.current.media.type)) {
|
if(!self.current.media.live) {
|
||||||
self._lastUpdate = Date.now();
|
self._lastUpdate = Date.now();
|
||||||
self._leadInterval = setInterval(function() {
|
self._leadInterval = setInterval(function() {
|
||||||
self._leadLoop();
|
self._leadLoop();
|
||||||
|
@ -453,7 +454,8 @@ Playlist.prototype.clean = function (filter) {
|
||||||
deleteNext();
|
deleteNext();
|
||||||
} else {
|
} else {
|
||||||
// refresh meta only once, at the end
|
// refresh meta only once, at the end
|
||||||
self.channel.broadcastPlaylistMeta();
|
self.channel.updatePlaylistMeta();
|
||||||
|
self.channel.sendPlaylistMeta(self.channel.users);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// start initial callback
|
// start initial callback
|
||||||
|
|
|
@ -329,16 +329,26 @@ function queue(pos, src) {
|
||||||
} else {
|
} else {
|
||||||
var link = $("#mediaurl").val();
|
var link = $("#mediaurl").val();
|
||||||
var data = parseMediaLink(link);
|
var data = parseMediaLink(link);
|
||||||
|
var duration = undefined;
|
||||||
|
if (link.indexOf("jw:") === 0) {
|
||||||
|
duration = parseInt($("#addfromurl-duration-val").val());
|
||||||
|
if (duration <= 0 || isNaN(duration)) {
|
||||||
|
duration = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (data.id == null || data.type == null) {
|
if (data.id == null || data.type == null) {
|
||||||
makeAlert("Error", "Failed to parse link. Please check that it is correct",
|
makeAlert("Error", "Failed to parse link. Please check that it is correct",
|
||||||
"alert-danger")
|
"alert-danger")
|
||||||
.insertAfter($("#addfromurl"));
|
.insertAfter($("#addfromurl"));
|
||||||
} else {
|
} else {
|
||||||
$("#mediaurl").val("");
|
$("#mediaurl").val("");
|
||||||
|
$("#addfromurl-duration").remove();
|
||||||
socket.emit("queue", {
|
socket.emit("queue", {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
type: data.type,
|
type: data.type,
|
||||||
pos: pos,
|
pos: pos,
|
||||||
|
duration: duration,
|
||||||
temp: $(".add-temp").prop("checked")
|
temp: $(".add-temp").prop("checked")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -350,9 +360,24 @@ $("#queue_end").click(queue.bind(this, "end", "url"));
|
||||||
$("#ce_queue_next").click(queue.bind(this, "next", "customembed"));
|
$("#ce_queue_next").click(queue.bind(this, "next", "customembed"));
|
||||||
$("#ce_queue_end").click(queue.bind(this, "end", "customembed"));
|
$("#ce_queue_end").click(queue.bind(this, "end", "customembed"));
|
||||||
|
|
||||||
$("#mediaurl").keydown(function(ev) {
|
$("#mediaurl").keyup(function(ev) {
|
||||||
if (ev.keyCode === 13) {
|
if (ev.keyCode === 13) {
|
||||||
queue("end", "url");
|
queue("end", "url");
|
||||||
|
} else if ($("#mediaurl").val().indexOf("jw:") === 0) {
|
||||||
|
var duration = $("#addfromurl-duration");
|
||||||
|
if (duration.length === 0) {
|
||||||
|
duration = $("<div/>")
|
||||||
|
.attr("id", "addfromurl-duration")
|
||||||
|
.appendTo($("#addfromurl"));
|
||||||
|
$("<span/>").text("JWPlayer Duration (seconds) (optional)")
|
||||||
|
.appendTo(duration);
|
||||||
|
$("<input/>").addClass("form-control")
|
||||||
|
.attr("type", "text")
|
||||||
|
.attr("id", "addfromurl-duration-val")
|
||||||
|
.appendTo($("#addfromurl-duration"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$("#addfromurl-duration").remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue