@clappr/hlsjs-playback 1.7.2 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hlsjs-playback.esm.js +120 -167
- package/dist/hlsjs-playback.external.js +120 -167
- package/dist/hlsjs-playback.external.min.js +1 -1
- package/dist/hlsjs-playback.external.min.js.map +1 -1
- package/dist/hlsjs-playback.js +120 -167
- package/dist/hlsjs-playback.min.js +1 -1
- package/dist/hlsjs-playback.min.js.map +1 -1
- package/package.json +4 -4
|
@@ -8,6 +8,83 @@
|
|
|
8
8
|
|
|
9
9
|
var HLSJS__default = /*#__PURE__*/_interopDefaultLegacy(HLSJS);
|
|
10
10
|
|
|
11
|
+
function _arrayLikeToArray(r, a) {
|
|
12
|
+
(null == a || a > r.length) && (a = r.length);
|
|
13
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
14
|
+
return n;
|
|
15
|
+
}
|
|
16
|
+
function _arrayWithoutHoles(r) {
|
|
17
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
18
|
+
}
|
|
19
|
+
function _assertThisInitialized(e) {
|
|
20
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
21
|
+
return e;
|
|
22
|
+
}
|
|
23
|
+
function _callSuper(t, o, e) {
|
|
24
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
25
|
+
}
|
|
26
|
+
function _classCallCheck(a, n) {
|
|
27
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
28
|
+
}
|
|
29
|
+
function _defineProperties(e, r) {
|
|
30
|
+
for (var t = 0; t < r.length; t++) {
|
|
31
|
+
var o = r[t];
|
|
32
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function _createClass(e, r, t) {
|
|
36
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
37
|
+
writable: !1
|
|
38
|
+
}), e;
|
|
39
|
+
}
|
|
40
|
+
function _defineProperty(e, r, t) {
|
|
41
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
42
|
+
value: t,
|
|
43
|
+
enumerable: !0,
|
|
44
|
+
configurable: !0,
|
|
45
|
+
writable: !0
|
|
46
|
+
}) : e[r] = t, e;
|
|
47
|
+
}
|
|
48
|
+
function _get() {
|
|
49
|
+
return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
|
|
50
|
+
var p = _superPropBase(e, t);
|
|
51
|
+
if (p) {
|
|
52
|
+
var n = Object.getOwnPropertyDescriptor(p, t);
|
|
53
|
+
return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
|
|
54
|
+
}
|
|
55
|
+
}, _get.apply(null, arguments);
|
|
56
|
+
}
|
|
57
|
+
function _getPrototypeOf(t) {
|
|
58
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
59
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
60
|
+
}, _getPrototypeOf(t);
|
|
61
|
+
}
|
|
62
|
+
function _inherits(t, e) {
|
|
63
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
64
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
65
|
+
constructor: {
|
|
66
|
+
value: t,
|
|
67
|
+
writable: !0,
|
|
68
|
+
configurable: !0
|
|
69
|
+
}
|
|
70
|
+
}), Object.defineProperty(t, "prototype", {
|
|
71
|
+
writable: !1
|
|
72
|
+
}), e && _setPrototypeOf(t, e);
|
|
73
|
+
}
|
|
74
|
+
function _isNativeReflectConstruct() {
|
|
75
|
+
try {
|
|
76
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
77
|
+
} catch (t) {}
|
|
78
|
+
return (_isNativeReflectConstruct = function () {
|
|
79
|
+
return !!t;
|
|
80
|
+
})();
|
|
81
|
+
}
|
|
82
|
+
function _iterableToArray(r) {
|
|
83
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
84
|
+
}
|
|
85
|
+
function _nonIterableSpread() {
|
|
86
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
87
|
+
}
|
|
11
88
|
function ownKeys(e, r) {
|
|
12
89
|
var t = Object.keys(e);
|
|
13
90
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -29,171 +106,49 @@
|
|
|
29
106
|
}
|
|
30
107
|
return e;
|
|
31
108
|
}
|
|
32
|
-
function
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
function _defineProperties(target, props) {
|
|
38
|
-
for (var i = 0; i < props.length; i++) {
|
|
39
|
-
var descriptor = props[i];
|
|
40
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
41
|
-
descriptor.configurable = true;
|
|
42
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
43
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
47
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
48
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
49
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
50
|
-
writable: false
|
|
51
|
-
});
|
|
52
|
-
return Constructor;
|
|
53
|
-
}
|
|
54
|
-
function _defineProperty(obj, key, value) {
|
|
55
|
-
key = _toPropertyKey(key);
|
|
56
|
-
if (key in obj) {
|
|
57
|
-
Object.defineProperty(obj, key, {
|
|
58
|
-
value: value,
|
|
59
|
-
enumerable: true,
|
|
60
|
-
configurable: true,
|
|
61
|
-
writable: true
|
|
62
|
-
});
|
|
63
|
-
} else {
|
|
64
|
-
obj[key] = value;
|
|
65
|
-
}
|
|
66
|
-
return obj;
|
|
67
|
-
}
|
|
68
|
-
function _inherits(subClass, superClass) {
|
|
69
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
70
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
71
|
-
}
|
|
72
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
73
|
-
constructor: {
|
|
74
|
-
value: subClass,
|
|
75
|
-
writable: true,
|
|
76
|
-
configurable: true
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
Object.defineProperty(subClass, "prototype", {
|
|
80
|
-
writable: false
|
|
81
|
-
});
|
|
82
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
83
|
-
}
|
|
84
|
-
function _getPrototypeOf(o) {
|
|
85
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
86
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
87
|
-
};
|
|
88
|
-
return _getPrototypeOf(o);
|
|
109
|
+
function _possibleConstructorReturn(t, e) {
|
|
110
|
+
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
111
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
112
|
+
return _assertThisInitialized(t);
|
|
89
113
|
}
|
|
90
|
-
function _setPrototypeOf(
|
|
91
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
};
|
|
95
|
-
return _setPrototypeOf(o, p);
|
|
114
|
+
function _setPrototypeOf(t, e) {
|
|
115
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
116
|
+
return t.__proto__ = e, t;
|
|
117
|
+
}, _setPrototypeOf(t, e);
|
|
96
118
|
}
|
|
97
|
-
function
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (typeof Proxy === "function") return true;
|
|
101
|
-
try {
|
|
102
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
103
|
-
return true;
|
|
104
|
-
} catch (e) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
function _assertThisInitialized(self) {
|
|
109
|
-
if (self === void 0) {
|
|
110
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
111
|
-
}
|
|
112
|
-
return self;
|
|
113
|
-
}
|
|
114
|
-
function _possibleConstructorReturn(self, call) {
|
|
115
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
116
|
-
return call;
|
|
117
|
-
} else if (call !== void 0) {
|
|
118
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
119
|
-
}
|
|
120
|
-
return _assertThisInitialized(self);
|
|
119
|
+
function _superPropBase(t, o) {
|
|
120
|
+
for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t)););
|
|
121
|
+
return t;
|
|
121
122
|
}
|
|
122
|
-
function
|
|
123
|
-
var
|
|
124
|
-
return function
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (hasNativeReflectConstruct) {
|
|
128
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
129
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
130
|
-
} else {
|
|
131
|
-
result = Super.apply(this, arguments);
|
|
132
|
-
}
|
|
133
|
-
return _possibleConstructorReturn(this, result);
|
|
134
|
-
};
|
|
123
|
+
function _superPropGet(t, o, e, r) {
|
|
124
|
+
var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e);
|
|
125
|
+
return 2 & r && "function" == typeof p ? function (t) {
|
|
126
|
+
return p.apply(e, t);
|
|
127
|
+
} : p;
|
|
135
128
|
}
|
|
136
|
-
function
|
|
137
|
-
|
|
138
|
-
object = _getPrototypeOf(object);
|
|
139
|
-
if (object === null) break;
|
|
140
|
-
}
|
|
141
|
-
return object;
|
|
129
|
+
function _toConsumableArray(r) {
|
|
130
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
142
131
|
}
|
|
143
|
-
function
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
151
|
-
if (desc.get) {
|
|
152
|
-
return desc.get.call(arguments.length < 3 ? target : receiver);
|
|
153
|
-
}
|
|
154
|
-
return desc.value;
|
|
155
|
-
};
|
|
132
|
+
function _toPrimitive(t, r) {
|
|
133
|
+
if ("object" != typeof t || !t) return t;
|
|
134
|
+
var e = t[Symbol.toPrimitive];
|
|
135
|
+
if (void 0 !== e) {
|
|
136
|
+
var i = e.call(t, r || "default");
|
|
137
|
+
if ("object" != typeof i) return i;
|
|
138
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
156
139
|
}
|
|
157
|
-
return
|
|
158
|
-
}
|
|
159
|
-
function _toConsumableArray(arr) {
|
|
160
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
161
|
-
}
|
|
162
|
-
function _arrayWithoutHoles(arr) {
|
|
163
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
164
|
-
}
|
|
165
|
-
function _iterableToArray(iter) {
|
|
166
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
167
|
-
}
|
|
168
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
169
|
-
if (!o) return;
|
|
170
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
171
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
172
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
173
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
174
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
140
|
+
return ("string" === r ? String : Number)(t);
|
|
175
141
|
}
|
|
176
|
-
function
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return arr2;
|
|
142
|
+
function _toPropertyKey(t) {
|
|
143
|
+
var i = _toPrimitive(t, "string");
|
|
144
|
+
return "symbol" == typeof i ? i : i + "";
|
|
180
145
|
}
|
|
181
|
-
function
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
var prim = input[Symbol.toPrimitive];
|
|
187
|
-
if (prim !== undefined) {
|
|
188
|
-
var res = prim.call(input, hint || "default");
|
|
189
|
-
if (typeof res !== "object") return res;
|
|
190
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
146
|
+
function _unsupportedIterableToArray(r, a) {
|
|
147
|
+
if (r) {
|
|
148
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
149
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
150
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
191
151
|
}
|
|
192
|
-
return (hint === "string" ? String : Number)(input);
|
|
193
|
-
}
|
|
194
|
-
function _toPropertyKey(arg) {
|
|
195
|
-
var key = _toPrimitive(arg, "string");
|
|
196
|
-
return typeof key === "symbol" ? key : String(key);
|
|
197
152
|
}
|
|
198
153
|
|
|
199
154
|
var now = core.Utils.now,
|
|
@@ -203,15 +158,13 @@
|
|
|
203
158
|
core.Events.register('PLAYBACK_FRAGMENT_CHANGED');
|
|
204
159
|
core.Events.register('PLAYBACK_FRAGMENT_PARSING_METADATA');
|
|
205
160
|
var HlsjsPlayback = /*#__PURE__*/function (_HTML5Video) {
|
|
206
|
-
_inherits(HlsjsPlayback, _HTML5Video);
|
|
207
|
-
var _super = _createSuper(HlsjsPlayback);
|
|
208
161
|
function HlsjsPlayback() {
|
|
209
162
|
var _this;
|
|
210
163
|
_classCallCheck(this, HlsjsPlayback);
|
|
211
164
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
212
165
|
args[_key] = arguments[_key];
|
|
213
166
|
}
|
|
214
|
-
_this =
|
|
167
|
+
_this = _callSuper(this, HlsjsPlayback, [].concat(args));
|
|
215
168
|
_this.options.hlsPlayback = _objectSpread2(_objectSpread2({}, _this.defaultOptions), _this.options.hlsPlayback);
|
|
216
169
|
_this._timeUpdateThrottleDelay = 200;
|
|
217
170
|
_this._timeUpdateFiringRate = 0.2;
|
|
@@ -219,7 +172,8 @@
|
|
|
219
172
|
_this._setInitialState();
|
|
220
173
|
return _this;
|
|
221
174
|
}
|
|
222
|
-
|
|
175
|
+
_inherits(HlsjsPlayback, _HTML5Video);
|
|
176
|
+
return _createClass(HlsjsPlayback, [{
|
|
223
177
|
key: "name",
|
|
224
178
|
get: function get() {
|
|
225
179
|
return 'hls';
|
|
@@ -228,7 +182,7 @@
|
|
|
228
182
|
key: "supportedVersion",
|
|
229
183
|
get: function get() {
|
|
230
184
|
return {
|
|
231
|
-
min: "0.11.
|
|
185
|
+
min: "0.11.4"
|
|
232
186
|
};
|
|
233
187
|
}
|
|
234
188
|
}, {
|
|
@@ -510,7 +464,7 @@
|
|
|
510
464
|
key: "render",
|
|
511
465
|
value: function render() {
|
|
512
466
|
this._ready();
|
|
513
|
-
return
|
|
467
|
+
return _superPropGet(HlsjsPlayback, "render", this, 3)([]);
|
|
514
468
|
}
|
|
515
469
|
}, {
|
|
516
470
|
key: "_ready",
|
|
@@ -754,7 +708,7 @@
|
|
|
754
708
|
var isSameDuration = Math.abs(this._lastDuration - duration) < this._durationChangeMinOffset;
|
|
755
709
|
if (isSameDuration) return;
|
|
756
710
|
this._lastDuration = duration;
|
|
757
|
-
|
|
711
|
+
_superPropGet(HlsjsPlayback, "_onDurationChange", this, 3)([]);
|
|
758
712
|
}
|
|
759
713
|
}, {
|
|
760
714
|
key: "_onProgress",
|
|
@@ -789,7 +743,7 @@
|
|
|
789
743
|
value: function play() {
|
|
790
744
|
!this._hls && this._setup();
|
|
791
745
|
!this._manifestLoading && !this.options.hlsPlayback.preload && this._hls.loadSource(this.options.src);
|
|
792
|
-
|
|
746
|
+
_superPropGet(HlsjsPlayback, "play", this, 3)([]);
|
|
793
747
|
this._startTimeUpdateTimer();
|
|
794
748
|
}
|
|
795
749
|
}, {
|
|
@@ -802,7 +756,7 @@
|
|
|
802
756
|
key: "stop",
|
|
803
757
|
value: function stop() {
|
|
804
758
|
this._stopTimeUpdateTimer();
|
|
805
|
-
if (this._hls)
|
|
759
|
+
if (this._hls) _superPropGet(HlsjsPlayback, "stop", this, 3)([]);
|
|
806
760
|
this._destroyHLSInstance();
|
|
807
761
|
}
|
|
808
762
|
}, {
|
|
@@ -810,7 +764,7 @@
|
|
|
810
764
|
value: function destroy() {
|
|
811
765
|
this._stopTimeUpdateTimer();
|
|
812
766
|
this._destroyHLSInstance();
|
|
813
|
-
|
|
767
|
+
_superPropGet(HlsjsPlayback, "destroy", this, 3)([]);
|
|
814
768
|
}
|
|
815
769
|
}, {
|
|
816
770
|
key: "_updatePlaybackType",
|
|
@@ -1022,7 +976,6 @@
|
|
|
1022
976
|
return HLSJS__default["default"];
|
|
1023
977
|
}
|
|
1024
978
|
}]);
|
|
1025
|
-
return HlsjsPlayback;
|
|
1026
979
|
}(core.HTML5Video);
|
|
1027
980
|
HlsjsPlayback.canPlay = function (resource, mimeType) {
|
|
1028
981
|
var resourceParts = resource.split('?')[0].match(/.*\.(.*)$/) || [];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var HlsjsPlayback=function(t,e){"use strict";function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=r(Hls);function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){s(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,p(i.key),i)}}function s(t,e,r){return(e=p(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function l(t){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},l(t)}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}function h(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function c(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,i=l(t);if(e){var n=l(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return h(this,r)}}function _(){return _="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=l(t)););return t}(t,e);if(i){var n=Object.getOwnPropertyDescriptor(i,e);return n.get?n.get.call(arguments.length<3?t:r):n.value}},_.apply(this,arguments)}function d(t){return function(t){if(Array.isArray(t))return f(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return f(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return f(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}function p(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var y=t.Utils.now,v=t.Utils.listContainsIgnoreCase;t.Events.register("PLAYBACK_FRAGMENT_CHANGED"),t.Events.register("PLAYBACK_FRAGMENT_PARSING_METADATA");var m=function(e){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&u(t,e)}(f,e);var r,n,s,h=c(f);function f(){var t;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,f);for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];return(t=h.call.apply(h,[this].concat(r))).options.hlsPlayback=a(a({},t.defaultOptions),t.options.hlsPlayback),t._timeUpdateThrottleDelay=200,t._timeUpdateFiringRate=.2,t._durationChangeMinOffset=.5,t._setInitialState(),t}return r=f,s=[{key:"HLSJS",get:function(){return i.default}}],(n=[{key:"name",get:function(){return"hls"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"levels",get:function(){return this._levels||[]}},{key:"currentLevel",get:function(){return null===this._currentLevel||void 0===this._currentLevel?-1:this._currentLevel},set:function(e){this._currentLevel=e,this.trigger(t.Events.PLAYBACK_LEVEL_SWITCH_START),this.options.playback.hlsUseNextLevel?this._hls.nextLevel=this._currentLevel:this._hls.currentLevel=this._currentLevel}},{key:"isReady",get:function(){return this._isReadyState}},{key:"latency",get:function(){return this._hls.latency}},{key:"currentProgramDateTime",get:function(){return this._hls.playingDate}},{key:"_startTime",get:function(){return this._playbackType===t.Playback.LIVE&&"EVENT"!==this._playlistType?this._extrapolatedStartTime:this._playableRegionStartTime}},{key:"_now",get:function(){return y()}},{key:"_extrapolatedStartTime",get:function(){if(!this._localStartTimeCorrelation)return this._playableRegionStartTime;var t=this._localStartTimeCorrelation,e=this._now-t.local,r=(t.remote+e)/1e3;return Math.min(r,this._playableRegionStartTime+this._extrapolatedWindowDuration)}},{key:"_extrapolatedEndTime",get:function(){var t=this._playableRegionStartTime+this._playableRegionDuration;if(!this._localEndTimeCorrelation)return t;var e=this._localEndTimeCorrelation,r=this._now-e.local,i=(e.remote+r)/1e3;return Math.max(t-this._extrapolatedWindowDuration,Math.min(i,t))}},{key:"_duration",get:function(){return this._extrapolatedEndTime-this._startTime}},{key:"_extrapolatedWindowDuration",get:function(){return null===this._segmentTargetDuration?0:this._extrapolatedWindowNumSegments*this._segmentTargetDuration}},{key:"bandwidthEstimate",get:function(){return this._hls&&this._hls.bandwidthEstimate}},{key:"defaultOptions",get:function(){return{preload:!0}}},{key:"customListeners",get:function(){return this.options.hlsPlayback&&this.options.hlsPlayback.customListeners||[]}},{key:"sourceMedia",get:function(){return this.options.src}},{key:"currentTimestamp",get:function(){return this._currentFragment?(this._currentFragment.programDateTime+1e3*(this.el.currentTime-this._currentFragment.start))/1e3:null}},{key:"_setInitialState",value:function(){this._minDvrSize=void 0===this.options.hlsMinimumDvrSize?60:this.options.hlsMinimumDvrSize,this._extrapolatedWindowNumSegments=this.options.playback&&void 0!==this.options.playback.extrapolatedWindowNumSegments?this.options.playback.extrapolatedWindowNumSegments:2,this._playbackType=t.Playback.VOD,this._lastTimeUpdate={current:0,total:0,firstFragDateTime:0},this._lastTimeUpdateFiredTime=0,this._lastDuration=null,this._playableRegionStartTime=0,this._localStartTimeCorrelation=null,this._localEndTimeCorrelation=null,this._playableRegionDuration=0,this._programDateTime=0,this._durationExcludesAfterLiveSyncPoint=!1,this._segmentTargetDuration=null,this._playlistType=null,this._recoverAttemptsRemaining=this.options.hlsRecoverAttempts||16}},{key:"_setup",value:function(){this._destroyHLSInstance(),this._createHLSInstance(),this._listenHLSEvents(),this._attachHLSMedia()}},{key:"_destroyHLSInstance",value:function(){this._hls&&(this._manifestLoading=!1,this._ccIsSetup=!1,this._ccTracksUpdated=!1,this._setInitialState(),this._hls.destroy(),this._hls=null)}},{key:"_createHLSInstance",value:function(){var t=a({},this.options.playback.hlsjsConfig);this._hls=new i.default(t)}},{key:"_attachHLSMedia",value:function(){this._hls&&this._hls.attachMedia(this.el)}},{key:"_listenHLSEvents",value:function(){var t=this;this._hls&&(this._hls.once(i.default.Events.MEDIA_ATTACHED,(function(){t.options.hlsPlayback.preload&&t._hls.loadSource(t.options.src)})),this._hls.on(i.default.Events.MANIFEST_LOADING,(function(){return t._manifestLoading=!0})),this._hls.on(i.default.Events.LEVEL_LOADED,(function(e,r){return t._updatePlaybackType(e,r)})),this._hls.on(i.default.Events.LEVEL_UPDATED,(function(e,r){return t._onLevelUpdated(e,r)})),this._hls.on(i.default.Events.LEVEL_SWITCHED,(function(e,r){return t._onLevelSwitch(e,r)})),this._hls.on(i.default.Events.FRAG_CHANGED,(function(e,r){return t._onFragmentChanged(e,r)})),this._hls.on(i.default.Events.FRAG_LOADED,(function(e,r){return t._onFragmentLoaded(e,r)})),this._hls.on(i.default.Events.FRAG_BUFFERED,(function(e,r){return t._onFragmentBuffered(e,r)})),this._hls.on(i.default.Events.FRAG_PARSING_METADATA,(function(e,r){return t._onFragmentParsingMetadata(e,r)})),this._hls.on(i.default.Events.ERROR,(function(e,r){return t._onHLSJSError(e,r)})),this._hls.on(i.default.Events.SUBTITLE_TRACK_LOADED,(function(e,r){return t._onSubtitleLoaded(e,r)})),this._hls.on(i.default.Events.SUBTITLE_TRACKS_UPDATED,(function(){return t._ccTracksUpdated=!0})),this.bindCustomListeners())}},{key:"bindCustomListeners",value:function(){var t=this;this.customListeners.forEach((function(e){var r=e.eventName,i=e.once?"once":"on";r&&t._hls["".concat(i)](r,e.callback)}))}},{key:"unbindCustomListeners",value:function(){var t=this;this.customListeners.forEach((function(e){var r=e.eventName;r&&t._hls.off(r,e.callback)}))}},{key:"_onFragmentParsingMetadata",value:function(e,r){this.trigger(t.Events.Custom.PLAYBACK_FRAGMENT_PARSING_METADATA,{evt:e,data:r})}},{key:"render",value:function(){return this._ready(),_(l(f.prototype),"render",this).call(this)}},{key:"_ready",value:function(){this._isReadyState||(!this._hls&&this._setup(),this._isReadyState=!0,this.trigger(t.Events.PLAYBACK_READY,this.name))}},{key:"_recover",value:function(e,r,i){if(this._recoveredDecodingError)if(this._recoveredAudioCodecError){t.Log.error("hlsjs: failed to recover",{evt:e,data:r}),i.level=t.PlayerError.Levels.FATAL;var n=this.createError(i);this.trigger(t.Events.PLAYBACK_ERROR,n),this.stop()}else this._recoveredAudioCodecError=!0,this._hls.swapAudioCodec(),this._hls.recoverMediaError(),this.play();else this._recoveredDecodingError=!0,this._hls.recoverMediaError(),this.play()}},{key:"_setupSrc",value:function(t){}},{key:"_startTimeUpdateTimer",value:function(){var t=this;this._timeUpdateTimer||(this._timeUpdateTimer=setInterval((function(){t._onDurationChange(),t._onTimeUpdate()}),100))}},{key:"_stopTimeUpdateTimer",value:function(){this._timeUpdateTimer&&(clearInterval(this._timeUpdateTimer),this._timeUpdateTimer=null)}},{key:"getProgramDateTime",value:function(){return this._programDateTime}},{key:"getDuration",value:function(){return this._duration}},{key:"getCurrentTime",value:function(){return Math.max(0,this.el.currentTime-this._startTime)}},{key:"getStartTimeOffset",value:function(){return this._startTime}},{key:"seekPercentage",value:function(t){var e=t>0?this._duration*(t/100):this._duration;this.seek(e)}},{key:"seek",value:function(e){e<0&&(t.Log.warn("Attempt to seek to a negative time. Resetting to live point. Use seekToLivePoint() to seek to the live point."),e=this.getDuration()),e+=this._startTime,this.el.currentTime=e}},{key:"seekToLivePoint",value:function(){this.seek(this.getDuration())}},{key:"_updateSettings",value:function(){this._playbackType===t.Playback.VOD?this.settings.left=["playpause","position","duration"]:this.dvrEnabled?this.settings.left=["playpause"]:this.settings.left=["playstop"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(t.Events.PLAYBACK_SETTINGSUPDATE)}},{key:"_onHLSJSError",value:function(e,r){var n,a={code:"".concat(r.type,"_").concat(r.details),description:"".concat(this.name," error: type: ").concat(r.type,", details: ").concat(r.details),raw:r};if(r.response&&(a.description+=", response: ".concat(JSON.stringify(r.response))),r.fatal)if(this._recoverAttemptsRemaining>0)switch(this._recoverAttemptsRemaining-=1,r.type){case i.default.ErrorTypes.NETWORK_ERROR:switch(r.details){case i.default.ErrorDetails.MANIFEST_LOAD_ERROR:case i.default.ErrorDetails.MANIFEST_LOAD_TIMEOUT:case i.default.ErrorDetails.MANIFEST_PARSING_ERROR:case i.default.ErrorDetails.LEVEL_LOAD_ERROR:case i.default.ErrorDetails.LEVEL_LOAD_TIMEOUT:t.Log.error("hlsjs: unrecoverable network fatal error.",{evt:e,data:r}),n=this.createError(a),this.trigger(t.Events.PLAYBACK_ERROR,n),this.stop();break;default:t.Log.warn("hlsjs: trying to recover from network error.",{evt:e,data:r}),a.level=t.PlayerError.Levels.WARN,this._hls.startLoad()}break;case i.default.ErrorTypes.MEDIA_ERROR:t.Log.warn("hlsjs: trying to recover from media error.",{evt:e,data:r}),a.level=t.PlayerError.Levels.WARN,this._recover(e,r,a);break;default:t.Log.error("hlsjs: could not recover from error.",{evt:e,data:r}),n=this.createError(a),this.trigger(t.Events.PLAYBACK_ERROR,n),this.stop()}else t.Log.error("hlsjs: could not recover from error after maximum number of attempts.",{evt:e,data:r}),n=this.createError(a),this.trigger(t.Events.PLAYBACK_ERROR,n),this.stop();else{if(this.options.playback.triggerFatalErrorOnResourceDenied&&this._keyIsDenied(r))return t.Log.error("hlsjs: could not load decrypt key.",{evt:e,data:r}),n=this.createError(a),this.trigger(t.Events.PLAYBACK_ERROR,n),void this.stop();a.level=t.PlayerError.Levels.WARN,t.Log.warn("hlsjs: non-fatal error occurred",{evt:e,data:r})}}},{key:"_keyIsDenied",value:function(t){return t.type===i.default.ErrorTypes.NETWORK_ERROR&&t.details===i.default.ErrorDetails.KEY_LOAD_ERROR&&t.response&&t.response.code>=400}},{key:"_onTimeUpdate",value:function(){var e={current:this.getCurrentTime(),total:this.getDuration(),firstFragDateTime:this.getProgramDateTime()};this._shouldThrottleTimeUpdate(e)||(this._lastTimeUpdate=e,this._lastTimeUpdateFiredTime=this._now,this.trigger(t.Events.PLAYBACK_TIMEUPDATE,e,this.name))}},{key:"_shouldThrottleTimeUpdate",value:function(t){var e=Math.abs(t.current-this._lastTimeUpdate.current)<this._timeUpdateFiringRate,r=Math.abs(t.total-this._lastTimeUpdate.total)<this._durationChangeMinOffset,i=t.firstFragDateTime===this._lastTimeUpdate.firstFragDateTime,n=e&&r&&i,a=this._now-this._lastTimeUpdateFiredTime<this._timeUpdateThrottleDelay;return n&&a}},{key:"_onDurationChange",value:function(){var t=this.getDuration();Math.abs(this._lastDuration-t)<this._durationChangeMinOffset||(this._lastDuration=t,_(l(f.prototype),"_onDurationChange",this).call(this))}},{key:"_onProgress",value:function(){if(this.el.buffered.length){for(var e=[],r=0,i=0;i<this.el.buffered.length;i++)e=[].concat(d(e),[{start:Math.max(0,this.el.buffered.start(i)-this._playableRegionStartTime),end:Math.max(0,this.el.buffered.end(i)-this._playableRegionStartTime)}]),this.el.currentTime>=e[i].start&&this.el.currentTime<=e[i].end&&(r=i);var n={start:e[r].start,current:e[r].end,total:this.getDuration()};this.trigger(t.Events.PLAYBACK_PROGRESS,n,e)}}},{key:"load",value:function(t){this._stopTimeUpdateTimer(),this.options.src=t,this._setup()}},{key:"play",value:function(){!this._hls&&this._setup(),!this._manifestLoading&&!this.options.hlsPlayback.preload&&this._hls.loadSource(this.options.src),_(l(f.prototype),"play",this).call(this),this._startTimeUpdateTimer()}},{key:"pause",value:function(){this._hls&&this.el.pause()}},{key:"stop",value:function(){this._stopTimeUpdateTimer(),this._hls&&_(l(f.prototype),"stop",this).call(this),this._destroyHLSInstance()}},{key:"destroy",value:function(){this._stopTimeUpdateTimer(),this._destroyHLSInstance(),_(l(f.prototype),"destroy",this).call(this)}},{key:"_updatePlaybackType",value:function(e,r){this._playbackType=r.details.live?t.Playback.LIVE:t.Playback.VOD,this._onLevelUpdated(e,r),this._ccTracksUpdated&&this._playbackType===t.Playback.LIVE&&this.hasClosedCaptionsTracks&&this._onSubtitleLoaded()}},{key:"_fillLevels",value:function(){this._levels=this._hls.levels.map((function(t,e){return{id:e,level:t,label:"".concat(t.bitrate/1e3,"Kbps")}})),this.trigger(t.Events.PLAYBACK_LEVELS_AVAILABLE,this._levels)}},{key:"_onLevelUpdated",value:function(e,r){this._segmentTargetDuration=r.details.targetduration,this._playlistType=r.details.type||null;var n=!1,a=!1,o=r.details.fragments,s=this._playableRegionStartTime,l=this._playableRegionDuration;if(0!==o.length){if(o[0].rawProgramDateTime&&(this._programDateTime=o[0].rawProgramDateTime),this._playableRegionStartTime!==o[0].start&&(n=!0,this._playableRegionStartTime=o[0].start),n)if(this._localStartTimeCorrelation){var u=this._localStartTimeCorrelation,h=this._now-u.local,c=(u.remote+h)/1e3;c<o[0].start?this._localStartTimeCorrelation={local:this._now,remote:1e3*o[0].start}:c>s+this._extrapolatedWindowDuration&&(this._localStartTimeCorrelation={local:this._now,remote:1e3*Math.max(o[0].start,s+this._extrapolatedWindowDuration)})}else this._localStartTimeCorrelation={local:this._now,remote:1e3*(o[0].start+this._extrapolatedWindowDuration/2)};var _=r.details.totalduration;if(this._playbackType===t.Playback.LIVE){var d=r.details.targetduration*((this.options.playback.hlsjsConfig||{}).liveSyncDurationCount||i.default.DefaultConfig.liveSyncDurationCount);d<=_?(_-=d,this._durationExcludesAfterLiveSyncPoint=!0):this._durationExcludesAfterLiveSyncPoint=!1}_!==this._playableRegionDuration&&(a=!0,this._playableRegionDuration=_);var f=o[0].start+_,p=s+l;if(f!==p)if(this._localEndTimeCorrelation){var y=this._localEndTimeCorrelation,v=this._now-y.local,m=(y.remote+v)/1e3;m>f?this._localEndTimeCorrelation={local:this._now,remote:1e3*f}:m<f-this._extrapolatedWindowDuration?this._localEndTimeCorrelation={local:this._now,remote:1e3*(f-this._extrapolatedWindowDuration)}:m>p&&(this._localEndTimeCorrelation={local:this._now,remote:1e3*p})}else this._localEndTimeCorrelation={local:this._now,remote:1e3*f};a&&this._onDurationChange(),n&&this._onProgress()}}},{key:"_onFragmentChanged",value:function(e,r){this._currentFragment=r.frag,this.trigger(t.Events.Custom.PLAYBACK_FRAGMENT_CHANGED,r)}},{key:"_onFragmentLoaded",value:function(e,r){this.trigger(t.Events.PLAYBACK_FRAGMENT_LOADED,r)}},{key:"_onFragmentBuffered",value:function(e,r){this.trigger(t.Events.PLAYBACK_FRAGMENT_BUFFERED,r)}},{key:"_onSubtitleLoaded",value:function(){if(!this._ccIsSetup){this.trigger(t.Events.PLAYBACK_SUBTITLE_AVAILABLE);var e=this._playbackType===t.Playback.LIVE?-1:this.closedCaptionsTrackId;this.closedCaptionsTrackId=e,this._ccIsSetup=!0}}},{key:"_onLevelSwitch",value:function(e,r){this.levels.length||this._fillLevels(),this.trigger(t.Events.PLAYBACK_LEVEL_SWITCH_END),this.trigger(t.Events.PLAYBACK_LEVEL_SWITCH,r);var i=this._hls.levels[r.level];i&&(this.highDefinition=i.height>=720||i.bitrate/1e3>=2e3,this.trigger(t.Events.PLAYBACK_HIGHDEFINITIONUPDATE,this.highDefinition),this.trigger(t.Events.PLAYBACK_BITRATE,{height:i.height,width:i.width,bandwidth:i.bitrate,bitrate:i.bitrate,level:r.level}))}},{key:"dvrEnabled",get:function(){return this._durationExcludesAfterLiveSyncPoint&&this._duration>=this._minDvrSize&&this.getPlaybackType()===t.Playback.LIVE}},{key:"getPlaybackType",value:function(){return this._playbackType}},{key:"isSeekEnabled",value:function(){return this._playbackType===t.Playback.VOD||this.dvrEnabled}}])&&o(r.prototype,n),s&&o(r,s),Object.defineProperty(r,"prototype",{writable:!1}),f}(t.HTML5Video);return m.canPlay=function(t,e){var r=t.split("?")[0].match(/.*\.(.*)$/)||[],n=r.length>1&&"m3u8"===r[1].toLowerCase()||v(e,["application/vnd.apple.mpegurl","application/x-mpegURL"]);return!(!i.default.isSupported()||!n)},m}(Clappr);
|
|
1
|
+
var HlsjsPlayback=function(t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=e(Hls);function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function n(t,e,r){return e=l(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,u()?Reflect.construct(e,r||[],l(t).constructor):e.apply(t,r))}function a(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,p(i.key),i)}}function o(t,e,r){return(e=p(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function s(){return s="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var i=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=l(t)););return t}(t,e);if(i){var n=Object.getOwnPropertyDescriptor(i,e);return n.get?n.get.call(arguments.length<3?t:r):n.value}},s.apply(null,arguments)}function l(t){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},l(t)}function u(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(u=function(){return!!t})()}function h(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function c(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?h(Object(r),!0).forEach((function(e){o(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function _(t,e){return _=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_(t,e)}function d(t,e,r,i){var n=s(l(1&i?t.prototype:t),e,r);return 2&i&&"function"==typeof n?function(t){return n.apply(r,t)}:n}function f(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}var y=t.Utils.now,v=t.Utils.listContainsIgnoreCase;t.Events.register("PLAYBACK_FRAGMENT_CHANGED"),t.Events.register("PLAYBACK_FRAGMENT_PARSING_METADATA");var m=function(e){function i(){var t;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i);for(var e=arguments.length,r=new Array(e),a=0;a<e;a++)r[a]=arguments[a];return(t=n(this,i,[].concat(r))).options.hlsPlayback=c(c({},t.defaultOptions),t.options.hlsPlayback),t._timeUpdateThrottleDelay=200,t._timeUpdateFiringRate=.2,t._durationChangeMinOffset=.5,t._setInitialState(),t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_(t,e)}(i,e),o=i,l=[{key:"HLSJS",get:function(){return r.default}}],(s=[{key:"name",get:function(){return"hls"}},{key:"supportedVersion",get:function(){return{min:"0.11.4"}}},{key:"levels",get:function(){return this._levels||[]}},{key:"currentLevel",get:function(){return null===this._currentLevel||void 0===this._currentLevel?-1:this._currentLevel},set:function(e){this._currentLevel=e,this.trigger(t.Events.PLAYBACK_LEVEL_SWITCH_START),this.options.playback.hlsUseNextLevel?this._hls.nextLevel=this._currentLevel:this._hls.currentLevel=this._currentLevel}},{key:"isReady",get:function(){return this._isReadyState}},{key:"latency",get:function(){return this._hls.latency}},{key:"currentProgramDateTime",get:function(){return this._hls.playingDate}},{key:"_startTime",get:function(){return this._playbackType===t.Playback.LIVE&&"EVENT"!==this._playlistType?this._extrapolatedStartTime:this._playableRegionStartTime}},{key:"_now",get:function(){return y()}},{key:"_extrapolatedStartTime",get:function(){if(!this._localStartTimeCorrelation)return this._playableRegionStartTime;var t=this._localStartTimeCorrelation,e=this._now-t.local,r=(t.remote+e)/1e3;return Math.min(r,this._playableRegionStartTime+this._extrapolatedWindowDuration)}},{key:"_extrapolatedEndTime",get:function(){var t=this._playableRegionStartTime+this._playableRegionDuration;if(!this._localEndTimeCorrelation)return t;var e=this._localEndTimeCorrelation,r=this._now-e.local,i=(e.remote+r)/1e3;return Math.max(t-this._extrapolatedWindowDuration,Math.min(i,t))}},{key:"_duration",get:function(){return this._extrapolatedEndTime-this._startTime}},{key:"_extrapolatedWindowDuration",get:function(){return null===this._segmentTargetDuration?0:this._extrapolatedWindowNumSegments*this._segmentTargetDuration}},{key:"bandwidthEstimate",get:function(){return this._hls&&this._hls.bandwidthEstimate}},{key:"defaultOptions",get:function(){return{preload:!0}}},{key:"customListeners",get:function(){return this.options.hlsPlayback&&this.options.hlsPlayback.customListeners||[]}},{key:"sourceMedia",get:function(){return this.options.src}},{key:"currentTimestamp",get:function(){return this._currentFragment?(this._currentFragment.programDateTime+1e3*(this.el.currentTime-this._currentFragment.start))/1e3:null}},{key:"_setInitialState",value:function(){this._minDvrSize=void 0===this.options.hlsMinimumDvrSize?60:this.options.hlsMinimumDvrSize,this._extrapolatedWindowNumSegments=this.options.playback&&void 0!==this.options.playback.extrapolatedWindowNumSegments?this.options.playback.extrapolatedWindowNumSegments:2,this._playbackType=t.Playback.VOD,this._lastTimeUpdate={current:0,total:0,firstFragDateTime:0},this._lastTimeUpdateFiredTime=0,this._lastDuration=null,this._playableRegionStartTime=0,this._localStartTimeCorrelation=null,this._localEndTimeCorrelation=null,this._playableRegionDuration=0,this._programDateTime=0,this._durationExcludesAfterLiveSyncPoint=!1,this._segmentTargetDuration=null,this._playlistType=null,this._recoverAttemptsRemaining=this.options.hlsRecoverAttempts||16}},{key:"_setup",value:function(){this._destroyHLSInstance(),this._createHLSInstance(),this._listenHLSEvents(),this._attachHLSMedia()}},{key:"_destroyHLSInstance",value:function(){this._hls&&(this._manifestLoading=!1,this._ccIsSetup=!1,this._ccTracksUpdated=!1,this._setInitialState(),this._hls.destroy(),this._hls=null)}},{key:"_createHLSInstance",value:function(){var t=c({},this.options.playback.hlsjsConfig);this._hls=new r.default(t)}},{key:"_attachHLSMedia",value:function(){this._hls&&this._hls.attachMedia(this.el)}},{key:"_listenHLSEvents",value:function(){var t=this;this._hls&&(this._hls.once(r.default.Events.MEDIA_ATTACHED,(function(){t.options.hlsPlayback.preload&&t._hls.loadSource(t.options.src)})),this._hls.on(r.default.Events.MANIFEST_LOADING,(function(){return t._manifestLoading=!0})),this._hls.on(r.default.Events.LEVEL_LOADED,(function(e,r){return t._updatePlaybackType(e,r)})),this._hls.on(r.default.Events.LEVEL_UPDATED,(function(e,r){return t._onLevelUpdated(e,r)})),this._hls.on(r.default.Events.LEVEL_SWITCHED,(function(e,r){return t._onLevelSwitch(e,r)})),this._hls.on(r.default.Events.FRAG_CHANGED,(function(e,r){return t._onFragmentChanged(e,r)})),this._hls.on(r.default.Events.FRAG_LOADED,(function(e,r){return t._onFragmentLoaded(e,r)})),this._hls.on(r.default.Events.FRAG_BUFFERED,(function(e,r){return t._onFragmentBuffered(e,r)})),this._hls.on(r.default.Events.FRAG_PARSING_METADATA,(function(e,r){return t._onFragmentParsingMetadata(e,r)})),this._hls.on(r.default.Events.ERROR,(function(e,r){return t._onHLSJSError(e,r)})),this._hls.on(r.default.Events.SUBTITLE_TRACK_LOADED,(function(e,r){return t._onSubtitleLoaded(e,r)})),this._hls.on(r.default.Events.SUBTITLE_TRACKS_UPDATED,(function(){return t._ccTracksUpdated=!0})),this.bindCustomListeners())}},{key:"bindCustomListeners",value:function(){var t=this;this.customListeners.forEach((function(e){var r=e.eventName,i=e.once?"once":"on";r&&t._hls["".concat(i)](r,e.callback)}))}},{key:"unbindCustomListeners",value:function(){var t=this;this.customListeners.forEach((function(e){var r=e.eventName;r&&t._hls.off(r,e.callback)}))}},{key:"_onFragmentParsingMetadata",value:function(e,r){this.trigger(t.Events.Custom.PLAYBACK_FRAGMENT_PARSING_METADATA,{evt:e,data:r})}},{key:"render",value:function(){return this._ready(),d(i,"render",this,3)([])}},{key:"_ready",value:function(){this._isReadyState||(!this._hls&&this._setup(),this._isReadyState=!0,this.trigger(t.Events.PLAYBACK_READY,this.name))}},{key:"_recover",value:function(e,r,i){if(this._recoveredDecodingError)if(this._recoveredAudioCodecError){t.Log.error("hlsjs: failed to recover",{evt:e,data:r}),i.level=t.PlayerError.Levels.FATAL;var n=this.createError(i);this.trigger(t.Events.PLAYBACK_ERROR,n),this.stop()}else this._recoveredAudioCodecError=!0,this._hls.swapAudioCodec(),this._hls.recoverMediaError(),this.play();else this._recoveredDecodingError=!0,this._hls.recoverMediaError(),this.play()}},{key:"_setupSrc",value:function(t){}},{key:"_startTimeUpdateTimer",value:function(){var t=this;this._timeUpdateTimer||(this._timeUpdateTimer=setInterval((function(){t._onDurationChange(),t._onTimeUpdate()}),100))}},{key:"_stopTimeUpdateTimer",value:function(){this._timeUpdateTimer&&(clearInterval(this._timeUpdateTimer),this._timeUpdateTimer=null)}},{key:"getProgramDateTime",value:function(){return this._programDateTime}},{key:"getDuration",value:function(){return this._duration}},{key:"getCurrentTime",value:function(){return Math.max(0,this.el.currentTime-this._startTime)}},{key:"getStartTimeOffset",value:function(){return this._startTime}},{key:"seekPercentage",value:function(t){var e=t>0?this._duration*(t/100):this._duration;this.seek(e)}},{key:"seek",value:function(e){e<0&&(t.Log.warn("Attempt to seek to a negative time. Resetting to live point. Use seekToLivePoint() to seek to the live point."),e=this.getDuration()),e+=this._startTime,this.el.currentTime=e}},{key:"seekToLivePoint",value:function(){this.seek(this.getDuration())}},{key:"_updateSettings",value:function(){this._playbackType===t.Playback.VOD?this.settings.left=["playpause","position","duration"]:this.dvrEnabled?this.settings.left=["playpause"]:this.settings.left=["playstop"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(t.Events.PLAYBACK_SETTINGSUPDATE)}},{key:"_onHLSJSError",value:function(e,i){var n,a={code:"".concat(i.type,"_").concat(i.details),description:"".concat(this.name," error: type: ").concat(i.type,", details: ").concat(i.details),raw:i};if(i.response&&(a.description+=", response: ".concat(JSON.stringify(i.response))),i.fatal)if(this._recoverAttemptsRemaining>0)switch(this._recoverAttemptsRemaining-=1,i.type){case r.default.ErrorTypes.NETWORK_ERROR:switch(i.details){case r.default.ErrorDetails.MANIFEST_LOAD_ERROR:case r.default.ErrorDetails.MANIFEST_LOAD_TIMEOUT:case r.default.ErrorDetails.MANIFEST_PARSING_ERROR:case r.default.ErrorDetails.LEVEL_LOAD_ERROR:case r.default.ErrorDetails.LEVEL_LOAD_TIMEOUT:t.Log.error("hlsjs: unrecoverable network fatal error.",{evt:e,data:i}),n=this.createError(a),this.trigger(t.Events.PLAYBACK_ERROR,n),this.stop();break;default:t.Log.warn("hlsjs: trying to recover from network error.",{evt:e,data:i}),a.level=t.PlayerError.Levels.WARN,this._hls.startLoad()}break;case r.default.ErrorTypes.MEDIA_ERROR:t.Log.warn("hlsjs: trying to recover from media error.",{evt:e,data:i}),a.level=t.PlayerError.Levels.WARN,this._recover(e,i,a);break;default:t.Log.error("hlsjs: could not recover from error.",{evt:e,data:i}),n=this.createError(a),this.trigger(t.Events.PLAYBACK_ERROR,n),this.stop()}else t.Log.error("hlsjs: could not recover from error after maximum number of attempts.",{evt:e,data:i}),n=this.createError(a),this.trigger(t.Events.PLAYBACK_ERROR,n),this.stop();else{if(this.options.playback.triggerFatalErrorOnResourceDenied&&this._keyIsDenied(i))return t.Log.error("hlsjs: could not load decrypt key.",{evt:e,data:i}),n=this.createError(a),this.trigger(t.Events.PLAYBACK_ERROR,n),void this.stop();a.level=t.PlayerError.Levels.WARN,t.Log.warn("hlsjs: non-fatal error occurred",{evt:e,data:i})}}},{key:"_keyIsDenied",value:function(t){return t.type===r.default.ErrorTypes.NETWORK_ERROR&&t.details===r.default.ErrorDetails.KEY_LOAD_ERROR&&t.response&&t.response.code>=400}},{key:"_onTimeUpdate",value:function(){var e={current:this.getCurrentTime(),total:this.getDuration(),firstFragDateTime:this.getProgramDateTime()};this._shouldThrottleTimeUpdate(e)||(this._lastTimeUpdate=e,this._lastTimeUpdateFiredTime=this._now,this.trigger(t.Events.PLAYBACK_TIMEUPDATE,e,this.name))}},{key:"_shouldThrottleTimeUpdate",value:function(t){var e=Math.abs(t.current-this._lastTimeUpdate.current)<this._timeUpdateFiringRate,r=Math.abs(t.total-this._lastTimeUpdate.total)<this._durationChangeMinOffset,i=t.firstFragDateTime===this._lastTimeUpdate.firstFragDateTime,n=e&&r&&i,a=this._now-this._lastTimeUpdateFiredTime<this._timeUpdateThrottleDelay;return n&&a}},{key:"_onDurationChange",value:function(){var t=this.getDuration();Math.abs(this._lastDuration-t)<this._durationChangeMinOffset||(this._lastDuration=t,d(i,"_onDurationChange",this,3)([]))}},{key:"_onProgress",value:function(){if(this.el.buffered.length){for(var e=[],r=0,i=0;i<this.el.buffered.length;i++)e=[].concat(f(e),[{start:Math.max(0,this.el.buffered.start(i)-this._playableRegionStartTime),end:Math.max(0,this.el.buffered.end(i)-this._playableRegionStartTime)}]),this.el.currentTime>=e[i].start&&this.el.currentTime<=e[i].end&&(r=i);var n={start:e[r].start,current:e[r].end,total:this.getDuration()};this.trigger(t.Events.PLAYBACK_PROGRESS,n,e)}}},{key:"load",value:function(t){this._stopTimeUpdateTimer(),this.options.src=t,this._setup()}},{key:"play",value:function(){!this._hls&&this._setup(),!this._manifestLoading&&!this.options.hlsPlayback.preload&&this._hls.loadSource(this.options.src),d(i,"play",this,3)([]),this._startTimeUpdateTimer()}},{key:"pause",value:function(){this._hls&&this.el.pause()}},{key:"stop",value:function(){this._stopTimeUpdateTimer(),this._hls&&d(i,"stop",this,3)([]),this._destroyHLSInstance()}},{key:"destroy",value:function(){this._stopTimeUpdateTimer(),this._destroyHLSInstance(),d(i,"destroy",this,3)([])}},{key:"_updatePlaybackType",value:function(e,r){this._playbackType=r.details.live?t.Playback.LIVE:t.Playback.VOD,this._onLevelUpdated(e,r),this._ccTracksUpdated&&this._playbackType===t.Playback.LIVE&&this.hasClosedCaptionsTracks&&this._onSubtitleLoaded()}},{key:"_fillLevels",value:function(){this._levels=this._hls.levels.map((function(t,e){return{id:e,level:t,label:"".concat(t.bitrate/1e3,"Kbps")}})),this.trigger(t.Events.PLAYBACK_LEVELS_AVAILABLE,this._levels)}},{key:"_onLevelUpdated",value:function(e,i){this._segmentTargetDuration=i.details.targetduration,this._playlistType=i.details.type||null;var n=!1,a=!1,o=i.details.fragments,s=this._playableRegionStartTime,l=this._playableRegionDuration;if(0!==o.length){if(o[0].rawProgramDateTime&&(this._programDateTime=o[0].rawProgramDateTime),this._playableRegionStartTime!==o[0].start&&(n=!0,this._playableRegionStartTime=o[0].start),n)if(this._localStartTimeCorrelation){var u=this._localStartTimeCorrelation,h=this._now-u.local,c=(u.remote+h)/1e3;c<o[0].start?this._localStartTimeCorrelation={local:this._now,remote:1e3*o[0].start}:c>s+this._extrapolatedWindowDuration&&(this._localStartTimeCorrelation={local:this._now,remote:1e3*Math.max(o[0].start,s+this._extrapolatedWindowDuration)})}else this._localStartTimeCorrelation={local:this._now,remote:1e3*(o[0].start+this._extrapolatedWindowDuration/2)};var _=i.details.totalduration;if(this._playbackType===t.Playback.LIVE){var d=i.details.targetduration*((this.options.playback.hlsjsConfig||{}).liveSyncDurationCount||r.default.DefaultConfig.liveSyncDurationCount);d<=_?(_-=d,this._durationExcludesAfterLiveSyncPoint=!0):this._durationExcludesAfterLiveSyncPoint=!1}_!==this._playableRegionDuration&&(a=!0,this._playableRegionDuration=_);var f=o[0].start+_,p=s+l;if(f!==p)if(this._localEndTimeCorrelation){var y=this._localEndTimeCorrelation,v=this._now-y.local,m=(y.remote+v)/1e3;m>f?this._localEndTimeCorrelation={local:this._now,remote:1e3*f}:m<f-this._extrapolatedWindowDuration?this._localEndTimeCorrelation={local:this._now,remote:1e3*(f-this._extrapolatedWindowDuration)}:m>p&&(this._localEndTimeCorrelation={local:this._now,remote:1e3*p})}else this._localEndTimeCorrelation={local:this._now,remote:1e3*f};a&&this._onDurationChange(),n&&this._onProgress()}}},{key:"_onFragmentChanged",value:function(e,r){this._currentFragment=r.frag,this.trigger(t.Events.Custom.PLAYBACK_FRAGMENT_CHANGED,r)}},{key:"_onFragmentLoaded",value:function(e,r){this.trigger(t.Events.PLAYBACK_FRAGMENT_LOADED,r)}},{key:"_onFragmentBuffered",value:function(e,r){this.trigger(t.Events.PLAYBACK_FRAGMENT_BUFFERED,r)}},{key:"_onSubtitleLoaded",value:function(){if(!this._ccIsSetup){this.trigger(t.Events.PLAYBACK_SUBTITLE_AVAILABLE);var e=this._playbackType===t.Playback.LIVE?-1:this.closedCaptionsTrackId;this.closedCaptionsTrackId=e,this._ccIsSetup=!0}}},{key:"_onLevelSwitch",value:function(e,r){this.levels.length||this._fillLevels(),this.trigger(t.Events.PLAYBACK_LEVEL_SWITCH_END),this.trigger(t.Events.PLAYBACK_LEVEL_SWITCH,r);var i=this._hls.levels[r.level];i&&(this.highDefinition=i.height>=720||i.bitrate/1e3>=2e3,this.trigger(t.Events.PLAYBACK_HIGHDEFINITIONUPDATE,this.highDefinition),this.trigger(t.Events.PLAYBACK_BITRATE,{height:i.height,width:i.width,bandwidth:i.bitrate,bitrate:i.bitrate,level:r.level}))}},{key:"dvrEnabled",get:function(){return this._durationExcludesAfterLiveSyncPoint&&this._duration>=this._minDvrSize&&this.getPlaybackType()===t.Playback.LIVE}},{key:"getPlaybackType",value:function(){return this._playbackType}},{key:"isSeekEnabled",value:function(){return this._playbackType===t.Playback.VOD||this.dvrEnabled}}])&&a(o.prototype,s),l&&a(o,l),Object.defineProperty(o,"prototype",{writable:!1}),o;var o,s,l}(t.HTML5Video);return m.canPlay=function(t,e){var i=t.split("?")[0].match(/.*\.(.*)$/)||[],n=i.length>1&&"m3u8"===i[1].toLowerCase()||v(e,["application/vnd.apple.mpegurl","application/x-mpegURL"]);return!(!r.default.isSupported()||!n)},m}(Clappr);
|
|
2
2
|
//# sourceMappingURL=hlsjs-playback.external.min.js.map
|