Add HLS support (and upgrade Video.JS)

This commit is contained in:
calzoneman 2016-08-06 21:14:52 -07:00
parent da99ea8288
commit d06c614ccc
10 changed files with 6217 additions and 1392 deletions

View File

@ -19,6 +19,7 @@ var order = [
'ustream.coffee',
'imgur.coffee',
'gdrive-youtube.coffee',
'hls.coffee',
'update.coffee'
];

23
player/hls.coffee Normal file
View File

@ -0,0 +1,23 @@
window.HLSPlayer = class HLSPlayer extends VideoJSPlayer
constructor: (data) ->
if not (this instanceof HLSPlayer)
return new HLSPlayer(data)
@setupMeta(data)
super(data)
load: (data) ->
@setupMeta(data)
super(data)
setupMeta: (data) ->
data.meta.direct =
# Quality is required for data.meta.direct processing but doesn't
# matter here because it's dictated by the stream. Arbitrarily
# choose 480.
480: [
{
link: data.id
contentType: 'application/x-mpegURL'
}
]

View File

@ -15,6 +15,7 @@ TYPE_MAP =
us: UstreamPlayer
im: ImgurPlayer
vm: VideoJSPlayer
hl: HLSPlayer
window.loadMediaPlayer = (data) ->
try

View File

@ -457,6 +457,13 @@ var Getters = {
callback(false, media);
},
/* HLS stream */
hl: function (id, callback) {
var title = "Livestream";
var media = new Media(id, title, "--:--", "hl");
callback(false, media);
},
/* imgur.com albums */
im: function (id, callback) {
/**

View File

@ -249,3 +249,4 @@ html(lang="en")
script(defer, src="/js/sc.js")
script(defer, src="/js/froogaloop.min.js")
script(defer, src="/js/video.js")
script(defer, src="/js/videojs-contrib-hls.min.js")

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
(function() {
var CUSTOM_EMBED_WARNING, CustomEmbedPlayer, DEFAULT_ERROR, DailymotionPlayer, EmbedPlayer, FilePlayer, GoogleDriveYouTubePlayer, HITBOX_ERROR, HitboxPlayer, ImgurPlayer, LivestreamPlayer, Player, RTMPPlayer, SoundCloudPlayer, TYPE_MAP, TwitchPlayer, USTREAM_ERROR, UstreamPlayer, VideoJSPlayer, VimeoPlayer, YouTubePlayer, codecToMimeType, genParam, sortSources,
var CUSTOM_EMBED_WARNING, CustomEmbedPlayer, DEFAULT_ERROR, DailymotionPlayer, EmbedPlayer, FilePlayer, GoogleDriveYouTubePlayer, HITBOX_ERROR, HLSPlayer, HitboxPlayer, ImgurPlayer, LivestreamPlayer, Player, RTMPPlayer, SoundCloudPlayer, TYPE_MAP, TwitchPlayer, USTREAM_ERROR, UstreamPlayer, VideoJSPlayer, VimeoPlayer, YouTubePlayer, codecToMimeType, genParam, sortSources,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
@ -1257,6 +1257,37 @@
})(Player);
window.HLSPlayer = HLSPlayer = (function(superClass) {
extend(HLSPlayer, superClass);
function HLSPlayer(data) {
if (!(this instanceof HLSPlayer)) {
return new HLSPlayer(data);
}
this.setupMeta(data);
HLSPlayer.__super__.constructor.call(this, data);
}
HLSPlayer.prototype.load = function(data) {
this.setupMeta(data);
return HLSPlayer.__super__.load.call(this, data);
};
HLSPlayer.prototype.setupMeta = function(data) {
return data.meta.direct = {
480: [
{
link: data.id,
contentType: 'application/x-mpegURL'
}
]
};
};
return HLSPlayer;
})(VideoJSPlayer);
TYPE_MAP = {
yt: YouTubePlayer,
vi: VimeoPlayer,
@ -1273,7 +1304,8 @@
hb: HitboxPlayer,
us: UstreamPlayer,
im: ImgurPlayer,
vm: VideoJSPlayer
vm: VideoJSPlayer,
hl: HLSPlayer
};
window.loadMediaPlayer = function(data) {

View File

@ -1366,6 +1366,13 @@ function parseMediaLink(url) {
};
}
if ((m = url.match(/(.*\.m3u8)/))) {
return {
id: m[1],
type: "hl"
};
}
/* Shorthand URIs */
// To catch Google Plus by ID alone
if ((m = url.match(/^(?:gp:)?(\d{21}_\d{19}_\d{19})/))) {
@ -1441,7 +1448,7 @@ function stripImages(msg){
return msg;
}
return msg.replace(IMAGE_MATCH, function(match,img){
return CHANNEL.opts.enable_link_regex ?
return CHANNEL.opts.enable_link_regex ?
'<a target="_blank" href="'+img+'">'+img+'</a>' : img;
});
}

File diff suppressed because it is too large Load Diff

12
www/js/videojs-contrib-hls.min.js vendored Normal file

File diff suppressed because one or more lines are too long