diff --git a/channel.js b/channel.js index a5649637..6e69000a 100644 --- a/channel.js +++ b/channel.js @@ -603,6 +603,13 @@ function mediaUpdate(chan, id) { setTimeout(function() { mediaUpdate(chan, id); }, 1000); } +function isLive(type) { + return type == "li" + || type == "tw" + || type == "rt" + || type == "jw"; +} + Channel.prototype.enqueue = function(data, user) { var idx = data.pos == "next" ? this.position + 1 : this.queue.length; @@ -668,9 +675,18 @@ Channel.prototype.enqueue = function(data, user) { }); this.broadcastPlaylistMeta(); break; + case "jw": + var media = new Media(data.id, "JWPlayer Stream - " + data.id, "--:--", "jw"); + media.queueby = user ? user.name : ""; + this.queue.splice(idx, 0, media); + this.sendAll("queue", { + media: media.pack(), + pos: idx + }); + this.broadcastPlaylistMeta(); + break; default: break; - } } } @@ -784,9 +800,7 @@ Channel.prototype.playNext = function() { }); // If it's not a livestream, enable autolead - if(this.leader == null && this.media.type != "tw" - && this.media.type != "li" - && this.media.type != "rt") { + if(this.leader == null && !isLive(this.media.type)) { this.time = new Date().getTime(); if(this.media.id != oid) { mediaUpdate(this, this.media.id); @@ -829,9 +843,7 @@ Channel.prototype.jumpTo = function(pos) { }); // If it's not a livestream, enable autolead - if(this.leader == null && this.media.type != "tw" - && this.media.type != "li" - && this.media.type != "rt") { + if(this.leader == null && !isLive(this.media.type)) { this.time = new Date().getTime(); if(this.media.id != oid) { mediaUpdate(this, this.media.id); @@ -908,8 +920,7 @@ Channel.prototype.tryUpdate = function(user, data) { return; } - if(this.media.type == "li" || this.media.type == "tw" || - this.media.type == "rt") { + if(isLive(this.media.type)) { return; } @@ -1284,9 +1295,7 @@ Channel.prototype.changeLeader = function(name) { } if(name == "") { this.logger.log("*** Resuming autolead"); - if(this.media != null && this.media.type != "li" - && this.media.type != "tw" - && this.media.type != "rt") { + if(this.media != null && !isLive(this.media.type)) { this.time = new Date().getTime(); this.i = 0; mediaUpdate(this, this.media.id); diff --git a/package.json b/package.json index c6568e15..4c751e41 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "1.4.1", + "version": "1.4.2", "repository": { "url": "http://github.com/calzoneman/sync" }, diff --git a/server.js b/server.js index e148a759..99fe5408 100644 --- a/server.js +++ b/server.js @@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -const VERSION = "1.4.1"; +const VERSION = "1.4.2"; var fs = require("fs"); var Logger = require("./logger.js"); diff --git a/www/assets/js/functions.js b/www/assets/js/functions.js index ef6a2c44..2ab54f5e 100644 --- a/www/assets/js/functions.js +++ b/www/assets/js/functions.js @@ -427,6 +427,10 @@ function parseVideoURL(url){ url = url.trim() if(typeof(url) != "string") return null; + if(url.indexOf("jw:") == 0) { + url = url.substring(3); + return [url, "jw"]; + } if(url.indexOf("rtmp://") == 0) { return [url, "rt"]; } diff --git a/www/assets/js/media.js b/www/assets/js/media.js index bc8c9515..a147ccc6 100644 --- a/www/assets/js/media.js +++ b/www/assets/js/media.js @@ -25,6 +25,9 @@ var Media = function(data) { case "rt": this.initRTMP(); break; + case "jw": + this.initJWPlayer(); + break; default: break; } @@ -278,6 +281,31 @@ Media.prototype.initRTMP = function() { this.seek = function() { } } +Media.prototype.initJWPlayer = function() { + this.removeOld(); + + jwplayer("ytapiplayer").setup({ + file: this.id, + width: VWIDTH, + height: VHEIGHT, + autostart: true + }); + setTimeout(function() {$("#ytapiplayer_logo").remove();}, 1000); + + this.load = function(data) { + this.id = data.id; + this.initJWPlayer(); + } + + this.pause = function() { } + + this.play = function() { } + + this.getTime = function() { } + + this.seek = function() { } +} + Media.prototype.update = function(data) { if(data.id != this.id) { if(data.currentTime < 0) { diff --git a/www/help.html b/www/help.html index 9fd9502c..084ae1b7 100644 --- a/www/help.html +++ b/www/help.html @@ -130,15 +130,17 @@
Below is an example of an entry in the playlist. Please note the control buttons only appear if you are a moderator or if the queue is unlocked. The button with vertical arrows is for moving videos in the playlist. Click and hold the button and drag the mouse up and down to move the video in the playlist. The red "X" button will remove the video from the playlist. The green play button will jump the playlist to that video. The "Next" button will move the video so that it plays after the current video.
diff --git a/www/index.html b/www/index.html index 85638fd6..543b1704 100644 --- a/www/index.html +++ b/www/index.html @@ -254,6 +254,7 @@ +