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 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
|
||||
var limit = {
|
||||
burst: 3,
|
||||
|
@ -1543,6 +1549,7 @@ Channel.prototype.handleQueue = function (user, data) {
|
|||
queueby: queueby,
|
||||
temp: temp,
|
||||
type: type,
|
||||
duration: duration,
|
||||
maxlength: this.hasPermission(user, "exceedmaxlength") ? 0 : this.opts.maxlength
|
||||
}, function (err, media) {
|
||||
if (err) {
|
||||
|
@ -1681,6 +1688,12 @@ Channel.prototype.addMedia = function (data, callback) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (data.duration) {
|
||||
media.seconds = data.duration;
|
||||
media.live = false;
|
||||
} else {
|
||||
media.live = true;
|
||||
}
|
||||
afterLookup(lock, false, media);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -181,7 +181,8 @@ Playlist.prototype.add = function(item, pos) {
|
|||
self.channel.sendAll("delete", {
|
||||
uid: it.uid
|
||||
});
|
||||
self.channel.broadcastPlaylistMeta();
|
||||
self.channel.updatePlaylistMeta();
|
||||
self.channel.sendPlaylistMeta(self.channel.users);
|
||||
}
|
||||
|
||||
if(pos == "append") {
|
||||
|
@ -387,7 +388,7 @@ Playlist.prototype.startPlayback = function (time) {
|
|||
self._leadInterval = false;
|
||||
}
|
||||
self.on("changeMedia")(self.current.media);
|
||||
if(!util.isLive(self.current.media.type)) {
|
||||
if(!self.current.media.live) {
|
||||
self._lastUpdate = Date.now();
|
||||
self._leadInterval = setInterval(function() {
|
||||
self._leadLoop();
|
||||
|
@ -453,7 +454,8 @@ Playlist.prototype.clean = function (filter) {
|
|||
deleteNext();
|
||||
} else {
|
||||
// refresh meta only once, at the end
|
||||
self.channel.broadcastPlaylistMeta();
|
||||
self.channel.updatePlaylistMeta();
|
||||
self.channel.sendPlaylistMeta(self.channel.users);
|
||||
}
|
||||
};
|
||||
// start initial callback
|
||||
|
|
|
@ -329,16 +329,26 @@ function queue(pos, src) {
|
|||
} else {
|
||||
var link = $("#mediaurl").val();
|
||||
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) {
|
||||
makeAlert("Error", "Failed to parse link. Please check that it is correct",
|
||||
"alert-danger")
|
||||
.insertAfter($("#addfromurl"));
|
||||
} else {
|
||||
$("#mediaurl").val("");
|
||||
$("#addfromurl-duration").remove();
|
||||
socket.emit("queue", {
|
||||
id: data.id,
|
||||
type: data.type,
|
||||
pos: pos,
|
||||
duration: duration,
|
||||
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_end").click(queue.bind(this, "end", "customembed"));
|
||||
|
||||
$("#mediaurl").keydown(function(ev) {
|
||||
$("#mediaurl").keyup(function(ev) {
|
||||
if (ev.keyCode === 13) {
|
||||
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