Merge pull request #431 from calzoneman/hitbox

Add hitbox support
This commit is contained in:
Calvin Montgomery 2015-01-27 00:29:44 -06:00
commit 583e7e7616
4 changed files with 82 additions and 2 deletions

View file

@ -910,7 +910,21 @@ var Getters = {
Logger.errlog.log("Unknown error for Google+ ID " + id + ": " + e.stack); Logger.errlog.log("Unknown error for Google+ ID " + id + ": " + e.stack);
} }
}); });
},
/* hitbox.tv */
hb: function (id, callback) {
var m = id.match(/([\w-]+)/);
if (m) {
id = m[1];
} else {
callback("Invalid ID", null);
return;
} }
var title = "Hitbox.tv - " + id;
var media = new Media(id, title, "--:--", "hb");
callback(false, media);
},
}; };
/** /**

View file

@ -238,6 +238,8 @@
return "https://docs.google.com/file/d/" + id; return "https://docs.google.com/file/d/" + id;
case "fi": case "fi":
return id; return id;
case "hb":
return "http://hitbox.tv/" + id;
default: default:
return ""; return "";
} }
@ -252,6 +254,7 @@
case "cu": case "cu":
case "im": case "im":
case "jw": case "jw":
case "hb":
return true; return true;
default: default:
return false; return false;

View file

@ -1043,6 +1043,59 @@ function FilePlayer(data) {
} }
}; };
var HitboxPlayer = function (data) {
var self = this;
self.videoId = data.id;
self.videoLength = data.seconds;
self.init = function () {
if (location.protocol.match(/^https/)) {
var div = makeAlert("Security Policy",
"You are currently connected via HTTPS but " +
"Hitbox only supports plain HTTP. Due to browser " +
"security policy, the embed player cannot be loaded. " +
"In order to watch the video, you must visit this page " +
"from its plain HTTP URL (your websocket will still be " +
"secured with HTTPS). Please complain to Hitbox about this.",
"alert-danger");
div.addClass("embed-responsive-item");
removeOld(div);
return;
}
var iframe = $("<iframe/>")
.attr("src", "http://hitbox.tv/embed/" + self.videoId)
.attr("webkitAllowFullScreen", "")
.attr("mozallowfullscreen", "")
.attr("allowFullScreen", "");
if (USEROPTS.wmode_transparent)
iframe.attr("wmode", "transparent");
removeOld(iframe);
self.player = iframe;
};
self.load = function (data) {
self.videoId = data.id;
self.videoLength = data.seconds;
self.init();
};
self.pause = function () { };
self.play = function () { };
self.getTime = function () { };
self.seek = function () { };
self.getVolume = function () { };
self.setVolume = function () { };
self.init();
};
function handleMediaUpdate(data) { function handleMediaUpdate(data) {
// Don't update if the position is past the video length, but // Don't update if the position is past the video length, but
// make an exception when the video length is 0 seconds // make an exception when the video length is 0 seconds
@ -1141,7 +1194,8 @@ var constructors = {
"cu": CustomPlayer, "cu": CustomPlayer,
"rt": RTMPPlayer, "rt": RTMPPlayer,
"rv": FilePlayer, "rv": FilePlayer,
"fi": FilePlayer "fi": FilePlayer,
"hb": HitboxPlayer
}; };
function loadMediaPlayer(data) { function loadMediaPlayer(data) {

View file

@ -47,6 +47,8 @@ function formatURL(data) {
return "https://docs.google.com/file/d/" + data.id; return "https://docs.google.com/file/d/" + data.id;
case "fi": case "fi":
return data.id; return data.id;
case "hb":
return "http://hitbox.tv/" + data.id;
default: default:
return "#"; return "#";
} }
@ -1306,6 +1308,13 @@ function parseMediaLink(url) {
}; };
} }
if ((m = url.match(/hitbox\.tv\/([^\?&#]+)/))) {
return {
id: m[1],
type: "hb"
};
}
/* Raw file */ /* Raw file */
var tmp = url.split("?")[0]; var tmp = url.split("?")[0];
if (tmp.match(/^https?:\/\//)) { if (tmp.match(/^https?:\/\//)) {