mirror of https://github.com/calzoneman/sync.git
Support RTMP streams
This commit is contained in:
parent
109260e46c
commit
176dd58284
20
channel.js
20
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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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"];
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue