Merge pull request #613 from calzoneman/videojs-hls

Add HLS support (and upgrade Video.JS)
This commit is contained in:
Calvin Montgomery 2016-08-09 22:42:12 -07:00 committed by GitHub
commit f9ccb1509b
11 changed files with 6222 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
sb: VideoJSPlayer
window.loadMediaPlayer = (data) ->

View File

@ -458,6 +458,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

@ -119,7 +119,7 @@
});
}
return result.join(":");
return result.join(":");
},
root.formatTime = function (sec) {
@ -242,6 +242,8 @@
return id;
case "hb":
return "http://hitbox.tv/" + id;
case "hl":
return id;
case "sb":
return "https://streamable.com/" + id;
default:
@ -259,6 +261,7 @@
case "im":
case "jw":
case "hb":
case "hl":
return true;
default:
return false;

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,
@ -1274,6 +1305,7 @@
us: UstreamPlayer,
im: ImgurPlayer,
vm: VideoJSPlayer,
hl: HLSPlayer,
sb: VideoJSPlayer
};

View File

@ -52,6 +52,8 @@ function formatURL(data) {
return data.id;
case "hb":
return "http://hitbox.tv/" + data.id;
case "hl":
return data.id;
case "sb":
return "https://streamable.com/" + data.id;
default:
@ -1368,6 +1370,13 @@ function parseMediaLink(url) {
};
}
if ((m = url.match(/(.*\.m3u8)/))) {
return {
id: m[1],
type: "hl"
};
}
if((m = url.match(/streamable\.com\/([\w-]+)/))) {
return {
id: m[1],
@ -1450,7 +1459,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