Add HLS support (and upgrade Video.JS)
This commit is contained in:
parent
da99ea8288
commit
d06c614ccc
|
@ -19,6 +19,7 @@ var order = [
|
|||
'ustream.coffee',
|
||||
'imgur.coffee',
|
||||
'gdrive-youtube.coffee',
|
||||
'hls.coffee',
|
||||
'update.coffee'
|
||||
];
|
||||
|
||||
|
|
23
player/hls.coffee
Normal file
23
player/hls.coffee
Normal 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'
|
||||
}
|
||||
]
|
|
@ -15,6 +15,7 @@ TYPE_MAP =
|
|||
us: UstreamPlayer
|
||||
im: ImgurPlayer
|
||||
vm: VideoJSPlayer
|
||||
hl: HLSPlayer
|
||||
|
||||
window.loadMediaPlayer = (data) ->
|
||||
try
|
||||
|
|
|
@ -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) {
|
||||
/**
|
||||
|
|
|
@ -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
|
@ -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) {
|
||||
|
|
|
@ -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})/))) {
|
||||
|
|
6516
www/js/video.js
6516
www/js/video.js
File diff suppressed because it is too large
Load diff
12
www/js/videojs-contrib-hls.min.js
vendored
Normal file
12
www/js/videojs-contrib-hls.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue