Add imgur album embedding

This commit is contained in:
Calvin Montgomery 2013-06-04 22:47:02 -04:00
parent ef6a415c1b
commit 8c6d2ccfb2
3 changed files with 51 additions and 6 deletions

View File

@ -952,12 +952,13 @@ function mediaUpdate(chan, id) {
}
function isLive(type) {
return type == "li"
|| type == "tw"
|| type == "jt"
|| type == "rt"
|| type == "jw"
|| type == "us";
return type == "li" // Livestream.com
|| type == "tw" // Twitch.tv
|| type == "jt" // Justin.tv
|| type == "rt" // RTMP
|| type == "jw" // JWPlayer
|| type == "us" // Ustream.tv
|| type == "im";// Imgur album
}
Channel.prototype.queueAdd = function(media, idx) {
@ -1050,6 +1051,12 @@ Channel.prototype.enqueue = function(data, user) {
this.autoTemp(media, user);
this.queueAdd(media, idx);
break;
case "im":
var media = new Media(data.id, "Imgur Album", "--:--", "im");
media.queueby = user ? user.name : "";
this.autoTemp(media, user);
this.queueAdd(media, idx);
break;
default:
break;
}

View File

@ -669,6 +669,8 @@ function parseVideoURL(url){
return [parseVimeo(url), "vi"];
else if(url.indexOf("dailymotion.com") != -1)
return [parseDailymotion(url), "dm"];
else if(url.indexOf("imgur.com") != -1)
return [parseImgur(url), "im"];
}
function parseYTURL(url) {
@ -743,6 +745,14 @@ function parseDailymotion(url) {
return null;
}
function parseImgur(url) {
var m = url.match(/imgur\.com\/a\/([a-zA-Z0-9]+)/);
if(m) {
return m[1];
}
return null;
}
function closePoll() {
if($("#pollcontainer .active").length != 0) {
var poll = $("#pollcontainer .active");

View File

@ -51,6 +51,9 @@ var Media = function(data) {
case "us":
this.initUstream();
break;
case "im":
this.initImgur();
break;
default:
this.nullPlayer();
break;
@ -467,6 +470,31 @@ Media.prototype.initUstream = function() {
this.seek = function() { }
}
Media.prototype.initImgur = function() {
var iframe = $("<iframe/>").insertBefore($("#ytapiplayer"));
$("#ytapiplayer").remove();
iframe.attr("id", "ytapiplayer");
iframe.attr("width", VWIDTH);
iframe.attr("height", VHEIGHT);
iframe.attr("src", "http://imgur.com/a/"+this.id+"/embed");
iframe.attr("frameborder", "0");
iframe.attr("scrolling", "no");
iframe.css("border", "none");
this.load = function(data) {
this.id = data.id;
this.initImgur()
}
this.pause = function() { }
this.play = function() { }
this.getTime = function() { }
this.seek = function() { }
}
Media.prototype.update = function(data) {
if(data.id && data.id != this.id) {
if(data.currentTime < 0) {