Add support for livestream

This commit is contained in:
calzoneman 2013-03-16 17:17:36 -05:00
parent bc187c99f5
commit 96bd8aa9bd
3 changed files with 29 additions and 0 deletions

View File

@ -283,6 +283,14 @@ Channel.prototype.enqueue = function(data) {
pos: idx
});
}
else if(data.type == "li") {
var media = new Media(data.id, "Livestream ~ " + data.id, 0, "li");
this.queue.splice(idx, 0, media);
this.sendAll('queue', {
media: media.pack(),
pos: idx
});
}
// Query metadata from Soundcloud
else if(data.type == "sc") {
var callback = (function(chan, id) { return function(res, data) {

View File

@ -146,6 +146,8 @@ function initCallbacks() {
updateYT(data);
else if(data.type == "tw")
loadTwitch(data.id);
else if(data.type == "li")
loadLivestream(data.id);
else if(data.type == "sc")
updateSC(data);
else if(data.type == "vi")

View File

@ -359,6 +359,14 @@ function loadTwitch(channel) {
swfobject.embedSWF( url, "ytapiplayer", '640', '390', "8", null, null, params, {} );
}
function loadLivestream(channel) {
MEDIATYPE = "li";
removeCurrentPlayer();
flashvars = { channel: channel };
params = { AllowScriptAccess: 'always' };
swfobject.embedSWF("http://cdn.livestream.com/chromelessPlayer/v20/playerapi.swf", "ytapiplayer", "640", "390", "9.0.0", "expressInstall.swf", flashvars, params);
}
function removeCurrentPlayer(){
var currentEmbed = $("#ytapiplayer");
var placeholder = $("<div/>").insertBefore(currentEmbed);
@ -373,6 +381,8 @@ function parseVideoURL(url){
return [parseYTURL(url), "yt"];
else if(url.indexOf("twitch") != -1)
return [parseTwitch(url), "tw"];
else if(url.indexOf("livestream") != -1)
return [parseLivestream(url), "li"];
else if(url.indexOf("soundcloud") != -1)
return [url, "sc"];
else if(url.indexOf("vimeo") != -1)
@ -411,6 +421,15 @@ function parseTwitch(url) {
return null;
}
function parseLivestream(url) {
var m = url.match(/livestream\.com\/([a-zA-Z0-9]*)/);
if(m) {
// Extract channel name
return m[1];
}
return null;
}
function parseVimeo(url) {
var m = url.match(/vimeo\.com\/([0-9]+)/);
if(m) {