From 96bd8aa9bd86544aa61dc27108206b086dbd70d7 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sat, 16 Mar 2013 17:17:36 -0500 Subject: [PATCH] Add support for livestream --- channel.js | 8 ++++++++ www/assets/js/callbacks.js | 2 ++ www/assets/js/functions.js | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/channel.js b/channel.js index cf834d86..93590b2c 100644 --- a/channel.js +++ b/channel.js @@ -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) { diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index 7518703d..45b489ff 100644 --- a/www/assets/js/callbacks.js +++ b/www/assets/js/callbacks.js @@ -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") diff --git a/www/assets/js/functions.js b/www/assets/js/functions.js index 1bdddc33..f4193973 100644 --- a/www/assets/js/functions.js +++ b/www/assets/js/functions.js @@ -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 = $("
").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) {