diff --git a/channel.js b/channel.js index dd85f49e..2f3cfee2 100644 --- a/channel.js +++ b/channel.js @@ -563,6 +563,14 @@ Channel.prototype.enqueue = function(data) { pos: idx }); break; + case "rt": + var media = new Media(data.id, "Livestream", "--:--", "rt"); + this.queue.splice(idx, 0, media); + this.sendAll("queue", { + media: media.pack(), + pos: idx + }); + break; default: break; @@ -658,7 +666,8 @@ 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 != "li" + && this.media.type != "rt") { this.time = new Date().getTime(); mediaUpdate(this, this.media.id); } @@ -698,7 +707,8 @@ 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 != "li" + && this.media.type != "rt") { this.time = new Date().getTime(); mediaUpdate(this, this.media.id); } @@ -733,7 +743,8 @@ Channel.prototype.tryUpdate = function(user, data) { return; } - if(this.media.type == "li" || this.media.type == "tw") { + if(this.media.type == "li" || this.media.type == "tw" || + this.media.type == "rt") { return; } @@ -1057,7 +1068,8 @@ 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 != "tw" + && this.media.type != "rt") { this.time = new Date().getTime(); this.i = 0; mediaUpdate(this, this.media.id); diff --git a/www/assets/js/client.js b/www/assets/js/client.js index b816df14..3f30e15f 100644 --- a/www/assets/js/client.js +++ b/www/assets/js/client.js @@ -394,7 +394,8 @@ function synchtubeLayout() { } function onYouTubeIframeAPIReady() { - PLAYER = new Media({id: "", type: "yt"}); + if(!PLAYER) + PLAYER = new Media({id: "", type: "yt"}); } function createCookie(name,value,days) { diff --git a/www/assets/js/functions.js b/www/assets/js/functions.js index e42a082b..288f94c2 100644 --- a/www/assets/js/functions.js +++ b/www/assets/js/functions.js @@ -360,7 +360,10 @@ function parseVideoURL(url){ url = url.trim() if(typeof(url) != "string") return null; - if(url.indexOf("youtu.be") != -1 || url.indexOf("youtube.com") != -1) { + if(url.indexOf("rtmp://") == 0) { + return [url, "rt"]; + } + else if(url.indexOf("youtu.be") != -1 || url.indexOf("youtube.com") != -1) { if(url.indexOf("playlist") != -1) { return [parseYTPlaylist(url), "yp"]; } diff --git a/www/assets/js/media.js b/www/assets/js/media.js index 3444a688..0d2e9172 100644 --- a/www/assets/js/media.js +++ b/www/assets/js/media.js @@ -21,6 +21,9 @@ var Media = function(data) { case "tw": this.initTwitch(); break; + case "rt": + this.initRTMP(); + break; default: break; } @@ -223,6 +226,34 @@ Media.prototype.initTwitch = function() { this.seek = function() { } } +Media.prototype.initRTMP = function() { + this.removeOld(); + var url = "http://fpdownload.adobe.com/strobe/FlashMediaPlayback_101.swf"; + var src = encodeURIComponent(this.id); + var params = { + allowFullScreen:"true", + allowScriptAccess:"always", + allowNetworking:"all", + wMode:"direct", + movie:"http://fpdownload.adobe.com/strobe/FlashMediaPlayback_101.swf", + flashvars:"src="+src+"&streamType=live&autoPlay=true" + }; + swfobject.embedSWF(url, "ytapiplayer", VWIDTH, VHEIGHT, "8", null, null, params, {} ); + + this.load = function(data) { + this.id = data.id; + this.initTwitch(); + } + + this.pause = function() { } + + this.play = function() { } + + this.getTime = function() { } + + this.seek = function() { } +} + Media.prototype.update = function(data) { if(data.id != this.id) { this.load(data);