@clappr/hlsjs-playback 1.1.0 → 1.2.0

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.
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@clappr/core'), require('hls.js')) :
3
3
  typeof define === 'function' && define.amd ? define(['@clappr/core', 'hls.js'], factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.HlsjsPlayback = factory(global.Clappr, global.Hls));
5
- })(this, (function (core, HLSJS) { 'use strict';
5
+ }(this, (function (core, HLSJS) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -10,49 +10,65 @@
10
10
 
11
11
  function ownKeys(object, enumerableOnly) {
12
12
  var keys = Object.keys(object);
13
+
13
14
  if (Object.getOwnPropertySymbols) {
14
15
  var symbols = Object.getOwnPropertySymbols(object);
15
- enumerableOnly && (symbols = symbols.filter(function (sym) {
16
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
17
- })), keys.push.apply(keys, symbols);
16
+
17
+ if (enumerableOnly) {
18
+ symbols = symbols.filter(function (sym) {
19
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
20
+ });
21
+ }
22
+
23
+ keys.push.apply(keys, symbols);
18
24
  }
25
+
19
26
  return keys;
20
27
  }
28
+
21
29
  function _objectSpread2(target) {
22
30
  for (var i = 1; i < arguments.length; i++) {
23
- var source = null != arguments[i] ? arguments[i] : {};
24
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
25
- _defineProperty(target, key, source[key]);
26
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
27
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
28
- });
31
+ var source = arguments[i] != null ? arguments[i] : {};
32
+
33
+ if (i % 2) {
34
+ ownKeys(Object(source), true).forEach(function (key) {
35
+ _defineProperty(target, key, source[key]);
36
+ });
37
+ } else if (Object.getOwnPropertyDescriptors) {
38
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
39
+ } else {
40
+ ownKeys(Object(source)).forEach(function (key) {
41
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
42
+ });
43
+ }
29
44
  }
45
+
30
46
  return target;
31
47
  }
48
+
32
49
  function _classCallCheck(instance, Constructor) {
33
50
  if (!(instance instanceof Constructor)) {
34
51
  throw new TypeError("Cannot call a class as a function");
35
52
  }
36
53
  }
54
+
37
55
  function _defineProperties(target, props) {
38
56
  for (var i = 0; i < props.length; i++) {
39
57
  var descriptor = props[i];
40
58
  descriptor.enumerable = descriptor.enumerable || false;
41
59
  descriptor.configurable = true;
42
60
  if ("value" in descriptor) descriptor.writable = true;
43
- Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
61
+ Object.defineProperty(target, descriptor.key, descriptor);
44
62
  }
45
63
  }
64
+
46
65
  function _createClass(Constructor, protoProps, staticProps) {
47
66
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
48
67
  if (staticProps) _defineProperties(Constructor, staticProps);
49
- Object.defineProperty(Constructor, "prototype", {
50
- writable: false
51
- });
52
68
  return Constructor;
53
69
  }
70
+
54
71
  function _defineProperty(obj, key, value) {
55
- key = _toPropertyKey(key);
56
72
  if (key in obj) {
57
73
  Object.defineProperty(obj, key, {
58
74
  value: value,
@@ -63,12 +79,15 @@
63
79
  } else {
64
80
  obj[key] = value;
65
81
  }
82
+
66
83
  return obj;
67
84
  }
85
+
68
86
  function _inherits(subClass, superClass) {
69
87
  if (typeof superClass !== "function" && superClass !== null) {
70
88
  throw new TypeError("Super expression must either be null or a function");
71
89
  }
90
+
72
91
  subClass.prototype = Object.create(superClass && superClass.prototype, {
73
92
  constructor: {
74
93
  value: subClass,
@@ -76,28 +95,30 @@
76
95
  configurable: true
77
96
  }
78
97
  });
79
- Object.defineProperty(subClass, "prototype", {
80
- writable: false
81
- });
82
98
  if (superClass) _setPrototypeOf(subClass, superClass);
83
99
  }
100
+
84
101
  function _getPrototypeOf(o) {
85
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
102
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
86
103
  return o.__proto__ || Object.getPrototypeOf(o);
87
104
  };
88
105
  return _getPrototypeOf(o);
89
106
  }
107
+
90
108
  function _setPrototypeOf(o, p) {
91
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
109
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
92
110
  o.__proto__ = p;
93
111
  return o;
94
112
  };
113
+
95
114
  return _setPrototypeOf(o, p);
96
115
  }
116
+
97
117
  function _isNativeReflectConstruct() {
98
118
  if (typeof Reflect === "undefined" || !Reflect.construct) return false;
99
119
  if (Reflect.construct.sham) return false;
100
120
  if (typeof Proxy === "function") return true;
121
+
101
122
  try {
102
123
  Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
103
124
  return true;
@@ -105,66 +126,84 @@
105
126
  return false;
106
127
  }
107
128
  }
129
+
108
130
  function _assertThisInitialized(self) {
109
131
  if (self === void 0) {
110
132
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
111
133
  }
134
+
112
135
  return self;
113
136
  }
137
+
114
138
  function _possibleConstructorReturn(self, call) {
115
139
  if (call && (typeof call === "object" || typeof call === "function")) {
116
140
  return call;
117
- } else if (call !== void 0) {
118
- throw new TypeError("Derived constructors may only return object or undefined");
119
141
  }
142
+
120
143
  return _assertThisInitialized(self);
121
144
  }
145
+
122
146
  function _createSuper(Derived) {
123
147
  var hasNativeReflectConstruct = _isNativeReflectConstruct();
148
+
124
149
  return function _createSuperInternal() {
125
150
  var Super = _getPrototypeOf(Derived),
126
- result;
151
+ result;
152
+
127
153
  if (hasNativeReflectConstruct) {
128
154
  var NewTarget = _getPrototypeOf(this).constructor;
155
+
129
156
  result = Reflect.construct(Super, arguments, NewTarget);
130
157
  } else {
131
158
  result = Super.apply(this, arguments);
132
159
  }
160
+
133
161
  return _possibleConstructorReturn(this, result);
134
162
  };
135
163
  }
164
+
136
165
  function _superPropBase(object, property) {
137
166
  while (!Object.prototype.hasOwnProperty.call(object, property)) {
138
167
  object = _getPrototypeOf(object);
139
168
  if (object === null) break;
140
169
  }
170
+
141
171
  return object;
142
172
  }
143
- function _get() {
173
+
174
+ function _get(target, property, receiver) {
144
175
  if (typeof Reflect !== "undefined" && Reflect.get) {
145
- _get = Reflect.get.bind();
176
+ _get = Reflect.get;
146
177
  } else {
147
178
  _get = function _get(target, property, receiver) {
148
179
  var base = _superPropBase(target, property);
180
+
149
181
  if (!base) return;
150
182
  var desc = Object.getOwnPropertyDescriptor(base, property);
183
+
151
184
  if (desc.get) {
152
- return desc.get.call(arguments.length < 3 ? target : receiver);
185
+ return desc.get.call(receiver);
153
186
  }
187
+
154
188
  return desc.value;
155
189
  };
156
190
  }
157
- return _get.apply(this, arguments);
191
+
192
+ return _get(target, property, receiver || target);
158
193
  }
194
+
159
195
  function _toConsumableArray(arr) {
160
196
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
161
197
  }
198
+
162
199
  function _arrayWithoutHoles(arr) {
163
200
  if (Array.isArray(arr)) return _arrayLikeToArray(arr);
164
201
  }
202
+
165
203
  function _iterableToArray(iter) {
166
204
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
167
205
  }
206
+
168
207
  function _unsupportedIterableToArray(o, minLen) {
169
208
  if (!o) return;
170
209
  if (typeof o === "string") return _arrayLikeToArray(o, minLen);
@@ -173,49 +212,48 @@
173
212
  if (n === "Map" || n === "Set") return Array.from(o);
174
213
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
175
214
  }
215
+
176
216
  function _arrayLikeToArray(arr, len) {
177
217
  if (len == null || len > arr.length) len = arr.length;
218
+
178
219
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
220
+
179
221
  return arr2;
180
222
  }
223
+
181
224
  function _nonIterableSpread() {
182
225
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
183
226
  }
184
- function _toPrimitive(input, hint) {
185
- if (typeof input !== "object" || input === null) return input;
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.");
191
- }
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
- }
198
227
 
199
228
  var now = core.Utils.now,
200
- listContainsIgnoreCase = core.Utils.listContainsIgnoreCase;
229
+ listContainsIgnoreCase = core.Utils.listContainsIgnoreCase;
201
230
  var AUTO = -1;
202
231
  var DEFAULT_RECOVER_ATTEMPTS = 16;
203
232
  core.Events.register('PLAYBACK_FRAGMENT_CHANGED');
204
233
  core.Events.register('PLAYBACK_FRAGMENT_PARSING_METADATA');
234
+
205
235
  var HlsjsPlayback = /*#__PURE__*/function (_HTML5Video) {
206
236
  _inherits(HlsjsPlayback, _HTML5Video);
237
+
207
238
  var _super = _createSuper(HlsjsPlayback);
239
+
208
240
  function HlsjsPlayback() {
209
241
  var _this;
242
+
210
243
  _classCallCheck(this, HlsjsPlayback);
244
+
211
245
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
212
246
  args[_key] = arguments[_key];
213
247
  }
248
+
214
249
  _this = _super.call.apply(_super, [this].concat(args));
215
250
  _this.options.hlsPlayback = _objectSpread2(_objectSpread2({}, _this.defaultOptions), _this.options.hlsPlayback);
251
+
216
252
  _this._setInitialState();
253
+
217
254
  return _this;
218
255
  }
256
+
219
257
  _createClass(HlsjsPlayback, [{
220
258
  key: "name",
221
259
  get: function get() {
@@ -225,7 +263,7 @@
225
263
  key: "supportedVersion",
226
264
  get: function get() {
227
265
  return {
228
- min: "0.4.27"
266
+ min: "0.4.18"
229
267
  };
230
268
  }
231
269
  }, {
@@ -248,6 +286,16 @@
248
286
  get: function get() {
249
287
  return this._isReadyState;
250
288
  }
289
+ }, {
290
+ key: "latency",
291
+ get: function get() {
292
+ return this._hls.latency;
293
+ }
294
+ }, {
295
+ key: "currentProgramDateTime",
296
+ get: function get() {
297
+ return this._hls.playingDate;
298
+ }
251
299
  }, {
252
300
  key: "_startTime",
253
301
  get: function get() {
@@ -258,23 +306,21 @@
258
306
  key: "_now",
259
307
  get: function get() {
260
308
  return now();
261
- }
262
-
263
- // the time in the video element which should represent the start of the sliding window
309
+ } // the time in the video element which should represent the start of the sliding window
264
310
  // extrapolated to increase in real time (instead of jumping as the early segments are removed)
311
+
265
312
  }, {
266
313
  key: "_extrapolatedStartTime",
267
314
  get: function get() {
268
315
  if (!this._localStartTimeCorrelation) return this._playableRegionStartTime;
269
316
  var corr = this._localStartTimeCorrelation;
270
317
  var timePassed = this._now - corr.local;
271
- var extrapolatedWindowStartTime = (corr.remote + timePassed) / 1000;
272
- // cap at the end of the extrapolated window duration
273
- return Math.min(extrapolatedWindowStartTime, this._playableRegionStartTime + this._extrapolatedWindowDuration);
274
- }
318
+ var extrapolatedWindowStartTime = (corr.remote + timePassed) / 1000; // cap at the end of the extrapolated window duration
275
319
 
276
- // the time in the video element which should represent the end of the content
320
+ return Math.min(extrapolatedWindowStartTime, this._playableRegionStartTime + this._extrapolatedWindowDuration);
321
+ } // the time in the video element which should represent the end of the content
277
322
  // extrapolated to increase in real time (instead of jumping as segments are added)
323
+
278
324
  }, {
279
325
  key: "_extrapolatedEndTime",
280
326
  get: function get() {
@@ -289,9 +335,7 @@
289
335
  key: "_duration",
290
336
  get: function get() {
291
337
  return this._extrapolatedEndTime - this._startTime;
292
- }
293
-
294
- // Returns the duration (seconds) of the window that the extrapolated start time is allowed
338
+ } // Returns the duration (seconds) of the window that the extrapolated start time is allowed
295
339
  // to move in before being capped.
296
340
  // The extrapolated start time should never reach the cap at the end of the window as the
297
341
  // window should slide as chunks are removed from the start.
@@ -308,6 +352,7 @@
308
352
  // . . . --> |
309
353
  // . . . .
310
354
  // extrapolatedStartTime
355
+
311
356
  }, {
312
357
  key: "_extrapolatedWindowDuration",
313
358
  get: function get() {
@@ -339,44 +384,44 @@
339
384
  }, {
340
385
  key: "_setInitialState",
341
386
  value: function _setInitialState() {
342
- this._minDvrSize = typeof this.options.hlsMinimumDvrSize === 'undefined' ? 60 : this.options.hlsMinimumDvrSize;
343
- // The size of the start time extrapolation window measured as a multiple of segments.
387
+ this._minDvrSize = typeof this.options.hlsMinimumDvrSize === 'undefined' ? 60 : this.options.hlsMinimumDvrSize; // The size of the start time extrapolation window measured as a multiple of segments.
344
388
  // Should be 2 or higher, or 0 to disable. Should only need to be increased above 2 if more than one segment is
345
389
  // removed from the start of the playlist at a time. E.g if the playlist is cached for 10 seconds and new chunks are
346
390
  // added/removed every 5.
391
+
347
392
  this._extrapolatedWindowNumSegments = !this.options.playback || typeof this.options.playback.extrapolatedWindowNumSegments === 'undefined' ? 2 : this.options.playback.extrapolatedWindowNumSegments;
348
393
  this._playbackType = core.Playback.VOD;
349
394
  this._lastTimeUpdate = {
350
395
  current: 0,
351
396
  total: 0
352
397
  };
353
- this._lastDuration = null;
354
- // for hls streams which have dvr with a sliding window,
398
+ this._lastDuration = null; // for hls streams which have dvr with a sliding window,
355
399
  // the content at the start of the playlist is removed as new
356
400
  // content is appended at the end.
357
401
  // this means the actual playable start time will increase as the
358
402
  // start content is deleted
359
403
  // For streams with dvr where the entire recording is kept from the
360
404
  // beginning this should stay as 0
361
- this._playableRegionStartTime = 0;
362
- // {local, remote} remote is the time in the video element that should represent 0
405
+
406
+ this._playableRegionStartTime = 0; // {local, remote} remote is the time in the video element that should represent 0
363
407
  // local is the system time when the 'remote' measurment took place
364
- this._localStartTimeCorrelation = null;
365
- // {local, remote} remote is the time in the video element that should represents the end
408
+
409
+ this._localStartTimeCorrelation = null; // {local, remote} remote is the time in the video element that should represents the end
366
410
  // local is the system time when the 'remote' measurment took place
367
- this._localEndTimeCorrelation = null;
368
- // if content is removed from the beginning then this empty area should
411
+
412
+ this._localEndTimeCorrelation = null; // if content is removed from the beginning then this empty area should
369
413
  // be ignored. "playableRegionDuration" excludes the empty area
370
- this._playableRegionDuration = 0;
371
- // #EXT-X-PROGRAM-DATE-TIME
372
- this._programDateTime = 0;
373
- // true when the actual duration is longer than hlsjs's live sync point
414
+
415
+ this._playableRegionDuration = 0; // #EXT-X-PROGRAM-DATE-TIME
416
+
417
+ this._programDateTime = 0; // true when the actual duration is longer than hlsjs's live sync point
374
418
  // when this is false playableRegionDuration will be the actual duration
375
419
  // when this is true playableRegionDuration will exclude the time after the sync point
376
- this._durationExcludesAfterLiveSyncPoint = false;
377
- // #EXT-X-TARGETDURATION
378
- this._segmentTargetDuration = null;
379
- // #EXT-X-PLAYLIST-TYPE
420
+
421
+ this._durationExcludesAfterLiveSyncPoint = false; // #EXT-X-TARGETDURATION
422
+
423
+ this._segmentTargetDuration = null; // #EXT-X-PLAYLIST-TYPE
424
+
380
425
  this._playlistType = null;
381
426
  this._recoverAttemptsRemaining = this.options.hlsRecoverAttempts || DEFAULT_RECOVER_ATTEMPTS;
382
427
  }
@@ -384,8 +429,11 @@
384
429
  key: "_setup",
385
430
  value: function _setup() {
386
431
  this._destroyHLSInstance();
432
+
387
433
  this._createHLSInstance();
434
+
388
435
  this._listenHLSEvents();
436
+
389
437
  this._attachHLSMedia();
390
438
  }
391
439
  }, {
@@ -395,66 +443,85 @@
395
443
  this._manifestParsed = false;
396
444
  this._ccIsSetup = false;
397
445
  this._ccTracksUpdated = false;
446
+
398
447
  this._setInitialState();
448
+
399
449
  this._hls.destroy();
450
+
400
451
  this._hls = null;
401
452
  }
402
453
  }, {
403
454
  key: "_createHLSInstance",
404
455
  value: function _createHLSInstance() {
405
456
  var config = _objectSpread2({}, this.options.playback.hlsjsConfig);
406
- this._hls = new HLSJS__default["default"](config);
457
+
458
+ this._hls = new HLSJS__default['default'](config);
407
459
  }
408
460
  }, {
409
461
  key: "_attachHLSMedia",
410
462
  value: function _attachHLSMedia() {
411
463
  if (!this._hls) return;
464
+
412
465
  this._hls.attachMedia(this.el);
413
466
  }
414
467
  }, {
415
468
  key: "_listenHLSEvents",
416
469
  value: function _listenHLSEvents() {
417
470
  var _this2 = this;
471
+
418
472
  if (!this._hls) return;
419
- this._hls.once(HLSJS__default["default"].Events.MEDIA_ATTACHED, function () {
473
+
474
+ this._hls.once(HLSJS__default['default'].Events.MEDIA_ATTACHED, function () {
420
475
  _this2.options.hlsPlayback.preload && _this2._hls.loadSource(_this2.options.src);
421
476
  });
422
- this._hls.on(HLSJS__default["default"].Events.MANIFEST_PARSED, function () {
477
+
478
+ this._hls.on(HLSJS__default['default'].Events.MANIFEST_PARSED, function () {
423
479
  return _this2._manifestParsed = true;
424
480
  });
425
- this._hls.on(HLSJS__default["default"].Events.LEVEL_LOADED, function (evt, data) {
481
+
482
+ this._hls.on(HLSJS__default['default'].Events.LEVEL_LOADED, function (evt, data) {
426
483
  return _this2._updatePlaybackType(evt, data);
427
484
  });
428
- this._hls.on(HLSJS__default["default"].Events.LEVEL_UPDATED, function (evt, data) {
485
+
486
+ this._hls.on(HLSJS__default['default'].Events.LEVEL_UPDATED, function (evt, data) {
429
487
  return _this2._onLevelUpdated(evt, data);
430
488
  });
431
- this._hls.on(HLSJS__default["default"].Events.LEVEL_SWITCHING, function (evt, data) {
489
+
490
+ this._hls.on(HLSJS__default['default'].Events.LEVEL_SWITCHING, function (evt, data) {
432
491
  return _this2._onLevelSwitch(evt, data);
433
492
  });
434
- this._hls.on(HLSJS__default["default"].Events.FRAG_CHANGED, function (evt, data) {
493
+
494
+ this._hls.on(HLSJS__default['default'].Events.FRAG_CHANGED, function (evt, data) {
435
495
  return _this2._onFragmentChanged(evt, data);
436
496
  });
437
- this._hls.on(HLSJS__default["default"].Events.FRAG_LOADED, function (evt, data) {
497
+
498
+ this._hls.on(HLSJS__default['default'].Events.FRAG_LOADED, function (evt, data) {
438
499
  return _this2._onFragmentLoaded(evt, data);
439
500
  });
440
- this._hls.on(HLSJS__default["default"].Events.FRAG_PARSING_METADATA, function (evt, data) {
501
+
502
+ this._hls.on(HLSJS__default['default'].Events.FRAG_PARSING_METADATA, function (evt, data) {
441
503
  return _this2._onFragmentParsingMetadata(evt, data);
442
504
  });
443
- this._hls.on(HLSJS__default["default"].Events.ERROR, function (evt, data) {
505
+
506
+ this._hls.on(HLSJS__default['default'].Events.ERROR, function (evt, data) {
444
507
  return _this2._onHLSJSError(evt, data);
445
508
  });
446
- this._hls.on(HLSJS__default["default"].Events.SUBTITLE_TRACK_LOADED, function (evt, data) {
509
+
510
+ this._hls.on(HLSJS__default['default'].Events.SUBTITLE_TRACK_LOADED, function (evt, data) {
447
511
  return _this2._onSubtitleLoaded(evt, data);
448
512
  });
449
- this._hls.on(HLSJS__default["default"].Events.SUBTITLE_TRACKS_UPDATED, function () {
513
+
514
+ this._hls.on(HLSJS__default['default'].Events.SUBTITLE_TRACKS_UPDATED, function () {
450
515
  return _this2._ccTracksUpdated = true;
451
516
  });
517
+
452
518
  this.bindCustomListeners();
453
519
  }
454
520
  }, {
455
521
  key: "bindCustomListeners",
456
522
  value: function bindCustomListeners() {
457
523
  var _this3 = this;
524
+
458
525
  this.customListeners.forEach(function (item) {
459
526
  var requestedEventName = item.eventName;
460
527
  var typeOfListener = item.once ? 'once' : 'on';
@@ -465,6 +532,7 @@
465
532
  key: "unbindCustomListeners",
466
533
  value: function unbindCustomListeners() {
467
534
  var _this4 = this;
535
+
468
536
  this.customListeners.forEach(function (item) {
469
537
  var requestedEventName = item.eventName;
470
538
  requestedEventName && _this4._hls.off(requestedEventName, item.callback);
@@ -482,6 +550,7 @@
482
550
  key: "render",
483
551
  value: function render() {
484
552
  this._ready();
553
+
485
554
  return _get(_getPrototypeOf(HlsjsPlayback.prototype), "render", this).call(this);
486
555
  }
487
556
  }, {
@@ -497,10 +566,13 @@
497
566
  value: function _recover(evt, data, error) {
498
567
  if (!this._recoveredDecodingError) {
499
568
  this._recoveredDecodingError = true;
569
+
500
570
  this._hls.recoverMediaError();
501
571
  } else if (!this._recoveredAudioCodecError) {
502
572
  this._recoveredAudioCodecError = true;
573
+
503
574
  this._hls.swapAudioCodec();
575
+
504
576
  this._hls.recoverMediaError();
505
577
  } else {
506
578
  core.Log.error('hlsjs: failed to recover', {
@@ -512,20 +584,22 @@
512
584
  this.trigger(core.Events.PLAYBACK_ERROR, formattedError);
513
585
  this.stop();
514
586
  }
515
- }
516
-
517
- // override
587
+ } // override
518
588
  // this playback manages the src on the video element itself
589
+
519
590
  }, {
520
591
  key: "_setupSrc",
521
592
  value: function _setupSrc(srcUrl) {} // eslint-disable-line no-unused-vars
593
+
522
594
  }, {
523
595
  key: "_startTimeUpdateTimer",
524
596
  value: function _startTimeUpdateTimer() {
525
597
  var _this5 = this;
598
+
526
599
  if (this._timeUpdateTimer) return;
527
600
  this._timeUpdateTimer = setInterval(function () {
528
601
  _this5._onDurationChange();
602
+
529
603
  _this5._onTimeUpdate();
530
604
  }, 100);
531
605
  }
@@ -540,11 +614,10 @@
540
614
  key: "getProgramDateTime",
541
615
  value: function getProgramDateTime() {
542
616
  return this._programDateTime;
543
- }
544
-
545
- // the duration on the video element itself should not be used
617
+ } // the duration on the video element itself should not be used
546
618
  // as this does not necesarily represent the duration of the stream
547
619
  // https://github.com/clappr/clappr/issues/668#issuecomment-157036678
620
+
548
621
  }, {
549
622
  key: "getDuration",
550
623
  value: function getDuration() {
@@ -557,11 +630,10 @@
557
630
  // eventually they will then be kicked to the end by hlsjs if they run out of buffer
558
631
  // before the official start time
559
632
  return Math.max(0, this.el.currentTime - this._startTime);
560
- }
561
-
562
- // the time that "0" now represents relative to when playback started
633
+ } // the time that "0" now represents relative to when playback started
563
634
  // for a stream with a sliding window this will increase as content is
564
635
  // removed from the beginning
636
+
565
637
  }, {
566
638
  key: "getStartTimeOffset",
567
639
  value: function getStartTimeOffset() {
@@ -579,8 +651,9 @@
579
651
  if (time < 0) {
580
652
  core.Log.warn('Attempt to seek to a negative time. Resetting to live point. Use seekToLivePoint() to seek to the live point.');
581
653
  time = this.getDuration();
582
- }
583
- // assume live if time within 3 seconds of end of stream
654
+ } // assume live if time within 3 seconds of end of stream
655
+
656
+
584
657
  this.dvrEnabled && this._updateDvr(time < this.getDuration() - 3);
585
658
  time += this._startTime;
586
659
  this.el.currentTime = time;
@@ -614,23 +687,24 @@
614
687
  raw: data
615
688
  };
616
689
  var formattedError;
617
- if (data.response) error.description += ", response: ".concat(JSON.stringify(data.response));
618
- // only report/handle errors if they are fatal
690
+ if (data.response) error.description += ", response: ".concat(JSON.stringify(data.response)); // only report/handle errors if they are fatal
619
691
  // hlsjs should automatically handle non fatal errors
692
+
620
693
  if (data.fatal) {
621
694
  if (this._recoverAttemptsRemaining > 0) {
622
695
  this._recoverAttemptsRemaining -= 1;
696
+
623
697
  switch (data.type) {
624
- case HLSJS__default["default"].ErrorTypes.NETWORK_ERROR:
698
+ case HLSJS__default['default'].ErrorTypes.NETWORK_ERROR:
625
699
  switch (data.details) {
626
700
  // The following network errors cannot be recovered with HLS.startLoad()
627
701
  // For more details, see https://github.com/video-dev/hls.js/blob/master/doc/design.md#error-detection-and-handling
628
702
  // For "level load" fatal errors, see https://github.com/video-dev/hls.js/issues/1138
629
- case HLSJS__default["default"].ErrorDetails.MANIFEST_LOAD_ERROR:
630
- case HLSJS__default["default"].ErrorDetails.MANIFEST_LOAD_TIMEOUT:
631
- case HLSJS__default["default"].ErrorDetails.MANIFEST_PARSING_ERROR:
632
- case HLSJS__default["default"].ErrorDetails.LEVEL_LOAD_ERROR:
633
- case HLSJS__default["default"].ErrorDetails.LEVEL_LOAD_TIMEOUT:
703
+ case HLSJS__default['default'].ErrorDetails.MANIFEST_LOAD_ERROR:
704
+ case HLSJS__default['default'].ErrorDetails.MANIFEST_LOAD_TIMEOUT:
705
+ case HLSJS__default['default'].ErrorDetails.MANIFEST_PARSING_ERROR:
706
+ case HLSJS__default['default'].ErrorDetails.LEVEL_LOAD_ERROR:
707
+ case HLSJS__default['default'].ErrorDetails.LEVEL_LOAD_TIMEOUT:
634
708
  core.Log.error('hlsjs: unrecoverable network fatal error.', {
635
709
  evt: evt,
636
710
  data: data
@@ -639,24 +713,32 @@
639
713
  this.trigger(core.Events.PLAYBACK_ERROR, formattedError);
640
714
  this.stop();
641
715
  break;
716
+
642
717
  default:
643
718
  core.Log.warn('hlsjs: trying to recover from network error.', {
644
719
  evt: evt,
645
720
  data: data
646
721
  });
647
722
  error.level = core.PlayerError.Levels.WARN;
723
+
648
724
  this._hls.startLoad();
725
+
649
726
  break;
650
727
  }
728
+
651
729
  break;
652
- case HLSJS__default["default"].ErrorTypes.MEDIA_ERROR:
730
+
731
+ case HLSJS__default['default'].ErrorTypes.MEDIA_ERROR:
653
732
  core.Log.warn('hlsjs: trying to recover from media error.', {
654
733
  evt: evt,
655
734
  data: data
656
735
  });
657
736
  error.level = core.PlayerError.Levels.WARN;
737
+
658
738
  this._recover(evt, data, error);
739
+
659
740
  break;
741
+
660
742
  default:
661
743
  core.Log.error('hlsjs: could not recover from error.', {
662
744
  evt: evt,
@@ -691,6 +773,7 @@
691
773
  this.stop();
692
774
  return;
693
775
  }
776
+
694
777
  error.level = core.PlayerError.Levels.WARN;
695
778
  core.Log.warn('hlsjs: non-fatal error occurred', {
696
779
  evt: evt,
@@ -701,7 +784,7 @@
701
784
  }, {
702
785
  key: "_keyIsDenied",
703
786
  value: function _keyIsDenied(data) {
704
- return data.type === HLSJS__default["default"].ErrorTypes.NETWORK_ERROR && data.details === HLSJS__default["default"].ErrorDetails.KEY_LOAD_ERROR && data.response && data.response.code >= 400;
787
+ return data.type === HLSJS__default['default'].ErrorTypes.NETWORK_ERROR && data.details === HLSJS__default['default'].ErrorDetails.KEY_LOAD_ERROR && data.response && data.response.code >= 400;
705
788
  }
706
789
  }, {
707
790
  key: "_onTimeUpdate",
@@ -722,6 +805,7 @@
722
805
  var duration = this.getDuration();
723
806
  if (this._lastDuration === duration) return;
724
807
  this._lastDuration = duration;
808
+
725
809
  _get(_getPrototypeOf(HlsjsPlayback.prototype), "_onDurationChange", this).call(this);
726
810
  }
727
811
  }, {
@@ -730,6 +814,7 @@
730
814
  if (!this.el.buffered.length) return;
731
815
  var buffered = [];
732
816
  var bufferedPos = 0;
817
+
733
818
  for (var i = 0; i < this.el.buffered.length; i++) {
734
819
  buffered = [].concat(_toConsumableArray(buffered), [{
735
820
  // for a stream with sliding window dvr something that is buffered my slide off the start of the timeline
@@ -738,6 +823,7 @@
738
823
  }]);
739
824
  if (this.el.currentTime >= buffered[i].start && this.el.currentTime <= buffered[i].end) bufferedPos = i;
740
825
  }
826
+
741
827
  var progress = {
742
828
  start: buffered[bufferedPos].start,
743
829
  current: buffered[bufferedPos].end,
@@ -749,7 +835,9 @@
749
835
  key: "load",
750
836
  value: function load(url) {
751
837
  this._stopTimeUpdateTimer();
838
+
752
839
  this.options.src = url;
840
+
753
841
  this._setup();
754
842
  }
755
843
  }, {
@@ -757,7 +845,9 @@
757
845
  value: function play() {
758
846
  !this._hls && this._setup();
759
847
  !this._manifestParsed && !this.options.hlsPlayback.preload && this._hls.loadSource(this.options.src);
848
+
760
849
  _get(_getPrototypeOf(HlsjsPlayback.prototype), "play", this).call(this);
850
+
761
851
  this._startTimeUpdateTimer();
762
852
  }
763
853
  }, {
@@ -771,22 +861,28 @@
771
861
  key: "stop",
772
862
  value: function stop() {
773
863
  this._stopTimeUpdateTimer();
864
+
774
865
  if (this._hls) _get(_getPrototypeOf(HlsjsPlayback.prototype), "stop", this).call(this);
866
+
775
867
  this._destroyHLSInstance();
776
868
  }
777
869
  }, {
778
870
  key: "destroy",
779
871
  value: function destroy() {
780
872
  this._stopTimeUpdateTimer();
873
+
781
874
  this._destroyHLSInstance();
875
+
782
876
  _get(_getPrototypeOf(HlsjsPlayback.prototype), "destroy", this).call(this);
783
877
  }
784
878
  }, {
785
879
  key: "_updatePlaybackType",
786
880
  value: function _updatePlaybackType(evt, data) {
787
881
  this._playbackType = data.details.live ? core.Playback.LIVE : core.Playback.VOD;
788
- this._onLevelUpdated(evt, data);
789
- // Live stream subtitle tracks detection hack (may not immediately available)
882
+
883
+ this._onLevelUpdated(evt, data); // Live stream subtitle tracks detection hack (may not immediately available)
884
+
885
+
790
886
  if (this._ccTracksUpdated && this._playbackType === core.Playback.LIVE && this.hasClosedCaptionsTracks) this._onSubtitleLoaded();
791
887
  }
792
888
  }, {
@@ -811,13 +907,15 @@
811
907
  var fragments = data.details.fragments;
812
908
  var previousPlayableRegionStartTime = this._playableRegionStartTime;
813
909
  var previousPlayableRegionDuration = this._playableRegionDuration;
814
- if (fragments.length === 0) return;
815
- // #EXT-X-PROGRAM-DATE-TIME
910
+ if (fragments.length === 0) return; // #EXT-X-PROGRAM-DATE-TIME
911
+
816
912
  if (fragments[0].rawProgramDateTime) this._programDateTime = fragments[0].rawProgramDateTime;
913
+
817
914
  if (this._playableRegionStartTime !== fragments[0].start) {
818
915
  startTimeChanged = true;
819
916
  this._playableRegionStartTime = fragments[0].start;
820
917
  }
918
+
821
919
  if (startTimeChanged) {
822
920
  if (!this._localStartTimeCorrelation) {
823
921
  // set the correlation to map to middle of the extrapolation window
@@ -828,9 +926,10 @@
828
926
  } else {
829
927
  // check if the correlation still works
830
928
  var corr = this._localStartTimeCorrelation;
831
- var timePassed = this._now - corr.local;
832
- // this should point to a time within the extrapolation window
929
+ var timePassed = this._now - corr.local; // this should point to a time within the extrapolation window
930
+
833
931
  var startTime = (corr.remote + timePassed) / 1000;
932
+
834
933
  if (startTime < fragments[0].start) {
835
934
  // our start time is now earlier than the first chunk
836
935
  // (maybe the chunk was removed early)
@@ -851,15 +950,17 @@
851
950
  }
852
951
  }
853
952
  }
854
- var newDuration = data.details.totalduration;
855
- // if it's a live stream then shorten the duration to remove access
953
+
954
+ var newDuration = data.details.totalduration; // if it's a live stream then shorten the duration to remove access
856
955
  // to the area after hlsjs's live sync point
857
956
  // seeks to areas after this point sometimes have issues
957
+
858
958
  if (this._playbackType === core.Playback.LIVE) {
859
959
  var fragmentTargetDuration = data.details.targetduration;
860
960
  var hlsjsConfig = this.options.playback.hlsjsConfig || {};
861
- var liveSyncDurationCount = hlsjsConfig.liveSyncDurationCount || HLSJS__default["default"].DefaultConfig.liveSyncDurationCount;
961
+ var liveSyncDurationCount = hlsjsConfig.liveSyncDurationCount || HLSJS__default['default'].DefaultConfig.liveSyncDurationCount;
862
962
  var hiddenAreaDuration = fragmentTargetDuration * liveSyncDurationCount;
963
+
863
964
  if (hiddenAreaDuration <= newDuration) {
864
965
  newDuration -= hiddenAreaDuration;
865
966
  this._durationExcludesAfterLiveSyncPoint = true;
@@ -867,15 +968,18 @@
867
968
  this._durationExcludesAfterLiveSyncPoint = false;
868
969
  }
869
970
  }
971
+
870
972
  if (newDuration !== this._playableRegionDuration) {
871
973
  durationChanged = true;
872
974
  this._playableRegionDuration = newDuration;
873
- }
874
- // Note the end time is not the playableRegionDuration
975
+ } // Note the end time is not the playableRegionDuration
875
976
  // The end time will always increase even if content is removed from the beginning
977
+
978
+
876
979
  var endTime = fragments[0].start + newDuration;
877
980
  var previousEndTime = previousPlayableRegionStartTime + previousPlayableRegionDuration;
878
981
  var endTimeChanged = endTime !== previousEndTime;
982
+
879
983
  if (endTimeChanged) {
880
984
  if (!this._localEndTimeCorrelation) {
881
985
  // set the correlation to map to the end
@@ -886,9 +990,12 @@
886
990
  } else {
887
991
  // check if the correlation still works
888
992
  var _corr = this._localEndTimeCorrelation;
889
- var _timePassed = this._now - _corr.local;
890
- // this should point to a time within the extrapolation window from the end
993
+
994
+ var _timePassed = this._now - _corr.local; // this should point to a time within the extrapolation window from the end
995
+
996
+
891
997
  var extrapolatedEndTime = (_corr.remote + _timePassed) / 1000;
998
+
892
999
  if (extrapolatedEndTime > endTime) {
893
1000
  this._localEndTimeCorrelation = {
894
1001
  local: this._now,
@@ -911,10 +1018,10 @@
911
1018
  };
912
1019
  }
913
1020
  }
914
- }
915
-
916
- // now that the values have been updated call any methods that use on them so they get the updated values
1021
+ } // now that the values have been updated call any methods that use on them so they get the updated values
917
1022
  // immediately
1023
+
1024
+
918
1025
  durationChanged && this._onDurationChange();
919
1026
  startTimeChanged && this._onProgress();
920
1027
  }
@@ -947,6 +1054,7 @@
947
1054
  this.trigger(core.Events.PLAYBACK_LEVEL_SWITCH_END);
948
1055
  this.trigger(core.Events.PLAYBACK_LEVEL_SWITCH, data);
949
1056
  var currentLevel = this._hls.levels[data.level];
1057
+
950
1058
  if (currentLevel) {
951
1059
  // TODO should highDefinition be private and maybe have a read only accessor if it's used somewhere
952
1060
  this.highDefinition = currentLevel.height >= 720 || currentLevel.bitrate / 1000 >= 2000;
@@ -982,17 +1090,19 @@
982
1090
  }], [{
983
1091
  key: "HLSJS",
984
1092
  get: function get() {
985
- return HLSJS__default["default"];
1093
+ return HLSJS__default['default'];
986
1094
  }
987
1095
  }]);
1096
+
988
1097
  return HlsjsPlayback;
989
1098
  }(core.HTML5Video);
1099
+
990
1100
  HlsjsPlayback.canPlay = function (resource, mimeType) {
991
1101
  var resourceParts = resource.split('?')[0].match(/.*\.(.*)$/) || [];
992
1102
  var isHls = resourceParts.length > 1 && resourceParts[1].toLowerCase() === 'm3u8' || listContainsIgnoreCase(mimeType, ['application/vnd.apple.mpegurl', 'application/x-mpegURL']);
993
- return !!(HLSJS__default["default"].isSupported() && isHls);
1103
+ return !!(HLSJS__default['default'].isSupported() && isHls);
994
1104
  };
995
1105
 
996
1106
  return HlsjsPlayback;
997
1107
 
998
- }));
1108
+ })));