@volcengine/veplayer-plugin 2.4.3-rc.1 → 2.4.5-rc.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.
Files changed (31) hide show
  1. package/esm/index.development.js +530 -1967
  2. package/esm/index.production.js +1 -1
  3. package/esm/veplayer.plugin.abr.development.js +3 -71
  4. package/esm/veplayer.plugin.abr.production.js +1 -1
  5. package/esm/veplayer.plugin.drm.development.js +3 -71
  6. package/esm/veplayer.plugin.drm.production.js +1 -1
  7. package/esm/veplayer.plugin.flv.development.js +196 -727
  8. package/esm/veplayer.plugin.flv.production.js +1 -1
  9. package/esm/veplayer.plugin.hls.development.js +368 -1342
  10. package/esm/veplayer.plugin.hls.production.js +1 -1
  11. package/esm/veplayer.plugin.mp4.development.js +5 -73
  12. package/esm/veplayer.plugin.mp4.production.js +1 -1
  13. package/esm/veplayer.plugin.rtm.development.js +4 -72
  14. package/esm/veplayer.plugin.rtm.production.js +1 -1
  15. package/esm/veplayer.plugin.shaka.development.js +4 -72
  16. package/esm/veplayer.plugin.shaka.production.js +1 -1
  17. package/package.json +1 -1
  18. package/umd/veplayer.plugin.abr.development.js +3 -71
  19. package/umd/veplayer.plugin.abr.production.js +1 -1
  20. package/umd/veplayer.plugin.drm.development.js +3 -71
  21. package/umd/veplayer.plugin.drm.production.js +1 -1
  22. package/umd/veplayer.plugin.flv.development.js +196 -727
  23. package/umd/veplayer.plugin.flv.production.js +1 -1
  24. package/umd/veplayer.plugin.hls.development.js +335 -1309
  25. package/umd/veplayer.plugin.hls.production.js +1 -1
  26. package/umd/veplayer.plugin.mp4.development.js +5 -73
  27. package/umd/veplayer.plugin.mp4.production.js +1 -1
  28. package/umd/veplayer.plugin.rtm.development.js +4 -72
  29. package/umd/veplayer.plugin.rtm.production.js +1 -1
  30. package/umd/veplayer.plugin.shaka.development.js +4 -72
  31. package/umd/veplayer.plugin.shaka.production.js +1 -1
@@ -67,10 +67,10 @@ function _regeneratorRuntime$1() {
67
67
  return obj[key] = value;
68
68
  };
69
69
  }
70
- function wrap(innerFn, outerFn, self2, tryLocsList) {
70
+ function wrap(innerFn, outerFn, self, tryLocsList) {
71
71
  var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []);
72
72
  return defineProperty(generator, "_invoke", {
73
- value: makeInvokeMethod(innerFn, self2, context)
73
+ value: makeInvokeMethod(innerFn, self, context)
74
74
  }), generator;
75
75
  }
76
76
  function tryCatch(fn, obj, arg) {
@@ -137,7 +137,7 @@ function _regeneratorRuntime$1() {
137
137
  }
138
138
  });
139
139
  }
140
- function makeInvokeMethod(innerFn, self2, context) {
140
+ function makeInvokeMethod(innerFn, self, context) {
141
141
  var state = "suspendedStart";
142
142
  return function(method, arg) {
143
143
  if ("executing" === state)
@@ -166,7 +166,7 @@ function _regeneratorRuntime$1() {
166
166
  } else
167
167
  "return" === context.method && context.abrupt("return", context.arg);
168
168
  state = "executing";
169
- var record = tryCatch(innerFn, self2, context);
169
+ var record = tryCatch(innerFn, self, context);
170
170
  if ("normal" === record.type) {
171
171
  if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel)
172
172
  continue;
@@ -248,9 +248,9 @@ function _regeneratorRuntime$1() {
248
248
  };
249
249
  }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
250
250
  return this;
251
- }), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self2, tryLocsList, PromiseImpl) {
251
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
252
252
  void 0 === PromiseImpl && (PromiseImpl = Promise);
253
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self2, tryLocsList), PromiseImpl);
253
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
254
254
  return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
255
255
  return result.done ? result.value : iter.next();
256
256
  });
@@ -385,9 +385,9 @@ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
385
385
  }
386
386
  function _asyncToGenerator$1(fn) {
387
387
  return function() {
388
- var self2 = this, args = arguments;
388
+ var self = this, args = arguments;
389
389
  return new Promise(function(resolve, reject) {
390
- var gen = fn.apply(self2, args);
390
+ var gen = fn.apply(self, args);
391
391
  function _next(value) {
392
392
  asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
393
393
  }
@@ -514,19 +514,19 @@ function _objectWithoutProperties$1(source, excluded) {
514
514
  }
515
515
  return target;
516
516
  }
517
- function _assertThisInitialized$2(self2) {
518
- if (self2 === void 0) {
517
+ function _assertThisInitialized$2(self) {
518
+ if (self === void 0) {
519
519
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
520
520
  }
521
- return self2;
521
+ return self;
522
522
  }
523
- function _possibleConstructorReturn$2(self2, call) {
523
+ function _possibleConstructorReturn$2(self, call) {
524
524
  if (call && (typeof call === "object" || typeof call === "function")) {
525
525
  return call;
526
526
  } else if (call !== void 0) {
527
527
  throw new TypeError("Derived constructors may only return object or undefined");
528
528
  }
529
- return _assertThisInitialized$2(self2);
529
+ return _assertThisInitialized$2(self);
530
530
  }
531
531
  function _createSuper$2(Derived) {
532
532
  var hasNativeReflectConstruct = _isNativeReflectConstruct$2();
@@ -1640,7 +1640,7 @@ util.getCurrentTimeByOffset = function(offsetTime, segments) {
1640
1640
  }
1641
1641
  return offsetTime;
1642
1642
  };
1643
- var version = "3.0.20-rc.6";
1643
+ var version = "3.0.19-rc.0";
1644
1644
  var ERROR_MAP = {
1645
1645
  1: 5101,
1646
1646
  2: 5102,
@@ -1749,7 +1749,8 @@ function hook(hookName, handler) {
1749
1749
  }
1750
1750
  if (this.__hooks && this.__hooks[hookName]) {
1751
1751
  try {
1752
- var preRet = runHooks(this, hookName, handler);
1752
+ var _this$__hooks$hookNam;
1753
+ var preRet = (_this$__hooks$hookNam = this.__hooks[hookName]).call.apply(_this$__hooks$hookNam, [this, this].concat(Array.prototype.slice.call(arguments)));
1753
1754
  if (preRet) {
1754
1755
  if (preRet.then) {
1755
1756
  preRet.then(function(isContinue) {
@@ -1774,19 +1775,6 @@ function hook(hookName, handler) {
1774
1775
  }
1775
1776
  }.bind(this);
1776
1777
  }
1777
- function findHookIndex(hookName, handler) {
1778
- var __hooks = this.__hooks;
1779
- if (!__hooks || !Array.isArray(__hooks[hookName])) {
1780
- return -1;
1781
- }
1782
- var hookHandlers = __hooks[hookName];
1783
- for (var i = 0; i < hookHandlers.length; i++) {
1784
- if (hookHandlers[i] === handler) {
1785
- return i;
1786
- }
1787
- }
1788
- return -1;
1789
- }
1790
1778
  function useHooks(hookName, handler) {
1791
1779
  var __hooks = this.__hooks;
1792
1780
  if (!__hooks) {
@@ -1796,12 +1784,7 @@ function useHooks(hookName, handler) {
1796
1784
  console.warn("has no supported hook which name [".concat(hookName, "]"));
1797
1785
  return false;
1798
1786
  }
1799
- if (!Array.isArray(__hooks[hookName])) {
1800
- __hooks[hookName] = [];
1801
- }
1802
- if (findHookIndex.call(this, hookName, handler) === -1) {
1803
- __hooks[hookName].push(handler);
1804
- }
1787
+ __hooks && (__hooks[hookName] = handler);
1805
1788
  return true;
1806
1789
  }
1807
1790
  function removeHooks(hookName, handler) {
@@ -1809,13 +1792,6 @@ function removeHooks(hookName, handler) {
1809
1792
  if (!__hooks) {
1810
1793
  return;
1811
1794
  }
1812
- if (Array.isArray(__hooks[hookName])) {
1813
- var hooks = __hooks[hookName];
1814
- var index = findHookIndex.call(this, hookName, handler);
1815
- if (index !== -1) {
1816
- hooks.splice(index, 1);
1817
- }
1818
- }
1819
1795
  delete __hooks[hookName];
1820
1796
  }
1821
1797
  function hooksDescriptor(instance) {
@@ -1837,38 +1813,6 @@ function hooksDescriptor(instance) {
1837
1813
  function delHooksDescriptor(instance) {
1838
1814
  instance.__hooks = null;
1839
1815
  }
1840
- function runHooks(obj, hookName, handler) {
1841
- for (var _len5 = arguments.length, args = new Array(_len5 > 3 ? _len5 - 3 : 0), _key5 = 3; _key5 < _len5; _key5++) {
1842
- args[_key5 - 3] = arguments[_key5];
1843
- }
1844
- if (obj.__hooks && Array.isArray(obj.__hooks[hookName])) {
1845
- var hooks = obj.__hooks[hookName];
1846
- var index = -1;
1847
- var runHooksRecursive = function runHooksRecursive2(obj2, hookName2, handler2) {
1848
- for (var _len6 = arguments.length, args2 = new Array(_len6 > 3 ? _len6 - 3 : 0), _key6 = 3; _key6 < _len6; _key6++) {
1849
- args2[_key6 - 3] = arguments[_key6];
1850
- }
1851
- index++;
1852
- if (hooks.length === 0 || index === hooks.length) {
1853
- return handler2.call.apply(handler2, [obj2, obj2].concat(args2));
1854
- }
1855
- var hook2 = hooks[index];
1856
- var ret = hook2.call.apply(hook2, [obj2, obj2].concat(args2));
1857
- if (ret && ret.then) {
1858
- return ret.then(function(data) {
1859
- return data === false ? null : runHooksRecursive2.apply(void 0, [obj2, hookName2, handler2].concat(args2));
1860
- }).catch(function(e) {
1861
- console.warn("[runHooks]".concat(hookName2, " reject"), e.message);
1862
- });
1863
- } else if (ret !== false) {
1864
- return runHooksRecursive2.apply(void 0, [obj2, hookName2, handler2].concat(args2));
1865
- }
1866
- };
1867
- return runHooksRecursive.apply(void 0, [obj, hookName, handler].concat(args));
1868
- } else {
1869
- return handler.call.apply(handler, [obj, obj].concat(args));
1870
- }
1871
- }
1872
1816
  function showErrorMsg(pluginName, msg) {
1873
1817
  XG_DEBUG.logError("[".concat(pluginName, "] event or callback cant be undefined or null when call ").concat(msg));
1874
1818
  }
@@ -2108,18 +2052,6 @@ var BasePlugin = /* @__PURE__ */ function() {
2108
2052
  }
2109
2053
  }
2110
2054
  }
2111
- }, {
2112
- key: "defineMethod",
2113
- value: function defineMethod(Obj, map) {
2114
- for (var key in map) {
2115
- if (Object.prototype.hasOwnProperty.call(map, key) && typeof map[key] === "function") {
2116
- Object.defineProperty(Obj, key, {
2117
- configurable: true,
2118
- value: map[key]
2119
- });
2120
- }
2121
- }
2122
- }
2123
2055
  }, {
2124
2056
  key: "defaultConfig",
2125
2057
  get: function get() {
@@ -2176,10 +2108,10 @@ function _regeneratorRuntime() {
2176
2108
  return obj[key] = value;
2177
2109
  };
2178
2110
  }
2179
- function wrap(innerFn, outerFn, self2, tryLocsList) {
2111
+ function wrap(innerFn, outerFn, self, tryLocsList) {
2180
2112
  var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []);
2181
2113
  return defineProperty(generator, "_invoke", {
2182
- value: makeInvokeMethod(innerFn, self2, context)
2114
+ value: makeInvokeMethod(innerFn, self, context)
2183
2115
  }), generator;
2184
2116
  }
2185
2117
  function tryCatch(fn, obj, arg) {
@@ -2246,7 +2178,7 @@ function _regeneratorRuntime() {
2246
2178
  }
2247
2179
  });
2248
2180
  }
2249
- function makeInvokeMethod(innerFn, self2, context) {
2181
+ function makeInvokeMethod(innerFn, self, context) {
2250
2182
  var state = "suspendedStart";
2251
2183
  return function(method, arg) {
2252
2184
  if ("executing" === state)
@@ -2275,7 +2207,7 @@ function _regeneratorRuntime() {
2275
2207
  } else
2276
2208
  "return" === context.method && context.abrupt("return", context.arg);
2277
2209
  state = "executing";
2278
- var record = tryCatch(innerFn, self2, context);
2210
+ var record = tryCatch(innerFn, self, context);
2279
2211
  if ("normal" === record.type) {
2280
2212
  if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel)
2281
2213
  continue;
@@ -2357,9 +2289,9 @@ function _regeneratorRuntime() {
2357
2289
  };
2358
2290
  }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
2359
2291
  return this;
2360
- }), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self2, tryLocsList, PromiseImpl) {
2292
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
2361
2293
  void 0 === PromiseImpl && (PromiseImpl = Promise);
2362
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self2, tryLocsList), PromiseImpl);
2294
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
2363
2295
  return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
2364
2296
  return result.done ? result.value : iter.next();
2365
2297
  });
@@ -2494,9 +2426,9 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2494
2426
  }
2495
2427
  function _asyncToGenerator(fn) {
2496
2428
  return function() {
2497
- var self2 = this, args = arguments;
2429
+ var self = this, args = arguments;
2498
2430
  return new Promise(function(resolve, reject) {
2499
- var gen = fn.apply(self2, args);
2431
+ var gen = fn.apply(self, args);
2500
2432
  function _next(value) {
2501
2433
  asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
2502
2434
  }
@@ -2670,19 +2602,19 @@ function _objectWithoutProperties(source, excluded) {
2670
2602
  }
2671
2603
  return target;
2672
2604
  }
2673
- function _assertThisInitialized$1(self2) {
2674
- if (self2 === void 0) {
2605
+ function _assertThisInitialized$1(self) {
2606
+ if (self === void 0) {
2675
2607
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
2676
2608
  }
2677
- return self2;
2609
+ return self;
2678
2610
  }
2679
- function _possibleConstructorReturn$1(self2, call) {
2611
+ function _possibleConstructorReturn$1(self, call) {
2680
2612
  if (call && (typeof call === "object" || typeof call === "function")) {
2681
2613
  return call;
2682
2614
  } else if (call !== void 0) {
2683
2615
  throw new TypeError("Derived constructors may only return object or undefined");
2684
2616
  }
2685
- return _assertThisInitialized$1(self2);
2617
+ return _assertThisInitialized$1(self);
2686
2618
  }
2687
2619
  function _createSuper$1(Derived) {
2688
2620
  var hasNativeReflectConstruct = _isNativeReflectConstruct$1();
@@ -2742,7 +2674,7 @@ function _arrayLikeToArray$1(arr, len) {
2742
2674
  arr2[i] = arr[i];
2743
2675
  return arr2;
2744
2676
  }
2745
- function _createForOfIteratorHelper$1(o, allowArrayLike) {
2677
+ function _createForOfIteratorHelper(o, allowArrayLike) {
2746
2678
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
2747
2679
  if (!it) {
2748
2680
  if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") {
@@ -2930,21 +2862,6 @@ var Buffer$1 = /* @__PURE__ */ function() {
2930
2862
  length: Buffer2.totalLength && Buffer2.totalLength(buffers)
2931
2863
  };
2932
2864
  }
2933
- }, {
2934
- key: "isBuffered",
2935
- value: function isBuffered(media, pos) {
2936
- if (media) {
2937
- var buffered = Buffer2.get(media);
2938
- if (buffered !== null && buffered !== void 0 && buffered.length) {
2939
- for (var i = 0; i < buffered.length; i++) {
2940
- if (pos >= buffered.start(i) && pos <= buffered.end(i)) {
2941
- return true;
2942
- }
2943
- }
2944
- }
2945
- }
2946
- return false;
2947
- }
2948
2865
  }]);
2949
2866
  return Buffer2;
2950
2867
  }();
@@ -3097,7 +3014,7 @@ var Logger$2 = /* @__PURE__ */ function() {
3097
3014
  this.logCache.apply(this, [LogCacheLevel.DEBUG].concat(args));
3098
3015
  if (Logger2.disabled)
3099
3016
  return;
3100
- (_console = console).debug.apply(_console, ["[".concat(nowTime$1(), "]"), this._prefix].concat(args));
3017
+ (_console = console).debug.apply(_console, [this._prefix, nowTime$1()].concat(args));
3101
3018
  }
3102
3019
  }, {
3103
3020
  key: "log",
@@ -3109,7 +3026,7 @@ var Logger$2 = /* @__PURE__ */ function() {
3109
3026
  this.logCache.apply(this, [LogCacheLevel.LOG].concat(args));
3110
3027
  if (Logger2.disabled)
3111
3028
  return;
3112
- (_console2 = console).log.apply(_console2, ["[".concat(nowTime$1(), "]"), this._prefix].concat(args));
3029
+ (_console2 = console).log.apply(_console2, [this._prefix, nowTime$1()].concat(args));
3113
3030
  }
3114
3031
  }, {
3115
3032
  key: "warn",
@@ -3121,7 +3038,7 @@ var Logger$2 = /* @__PURE__ */ function() {
3121
3038
  this.logCache.apply(this, [LogCacheLevel.WARN].concat(args));
3122
3039
  if (Logger2.disabled)
3123
3040
  return;
3124
- (_console3 = console).warn.apply(_console3, ["[".concat(nowTime$1(), "]"), this._prefix].concat(args));
3041
+ (_console3 = console).warn.apply(_console3, [this._prefix, nowTime$1()].concat(args));
3125
3042
  }
3126
3043
  }, {
3127
3044
  key: "error",
@@ -3133,7 +3050,7 @@ var Logger$2 = /* @__PURE__ */ function() {
3133
3050
  this.logCache.apply(this, [LogCacheLevel.ERROR].concat(args));
3134
3051
  if (Logger2.disabled)
3135
3052
  return;
3136
- (_console4 = console).error.apply(_console4, ["[".concat(nowTime$1(), "]"), this._prefix].concat(args));
3053
+ (_console4 = console).error.apply(_console4, [this._prefix, nowTime$1()].concat(args));
3137
3054
  }
3138
3055
  }, {
3139
3056
  key: "logCache",
@@ -3148,7 +3065,7 @@ var Logger$2 = /* @__PURE__ */ function() {
3148
3065
  var finLogText = logText.map(function(item) {
3149
3066
  return logable(item);
3150
3067
  });
3151
- text = "[".concat(nowTime$1(), "]") + this._prefix + JSON.stringify(finLogText);
3068
+ text = this._prefix + nowTime$1() + JSON.stringify(finLogText);
3152
3069
  } catch (e) {
3153
3070
  return;
3154
3071
  }
@@ -4064,8 +3981,8 @@ function createResponse(data, done, response, contentLength, age, startTime, fir
4064
3981
  response
4065
3982
  };
4066
3983
  }
4067
- function calculateSpeed(byteLen, milliSecond) {
4068
- return Math.round(byteLen * 8 * 1e3 / milliSecond / 1024);
3984
+ function calculateSpeed(byteLen, millisec) {
3985
+ return Math.round(byteLen * 8 * 1e3 / millisec / 1024);
4069
3986
  }
4070
3987
  var EVENT = {
4071
3988
  ERROR: "error",
@@ -4077,7 +3994,6 @@ var EVENT = {
4077
3994
  SOURCEBUFFER_CREATED: "core.sourcebuffercreated",
4078
3995
  MEDIASOURCE_OPENED: "core.mediasourceopened",
4079
3996
  ANALYZE_DURATION_EXCEEDED: "core.analyzedurationexceeded",
4080
- APPEND_BUFFER: "core.appendbuffer",
4081
3997
  REMOVE_BUFFER: "core.removebuffer",
4082
3998
  BUFFEREOS: "core.buffereos",
4083
3999
  KEYFRAME: "core.keyframe",
@@ -4850,7 +4766,7 @@ var XhrLoader = /* @__PURE__ */ function(_EventEmitter) {
4850
4766
  value: function _getHeaders(xhr) {
4851
4767
  var headerLines = xhr.getAllResponseHeaders().trim().split("\r\n");
4852
4768
  var headers = {};
4853
- var _iterator = _createForOfIteratorHelper$1(headerLines), _step;
4769
+ var _iterator = _createForOfIteratorHelper(headerLines), _step;
4854
4770
  try {
4855
4771
  for (_iterator.s(); !(_step = _iterator.n()).done; ) {
4856
4772
  var header = _step.value;
@@ -4872,7 +4788,7 @@ var XhrLoader = /* @__PURE__ */ function(_EventEmitter) {
4872
4788
  }]);
4873
4789
  return XhrLoader2;
4874
4790
  }(EventEmitter);
4875
- var _excluded$2 = ["retry", "retryDelay", "onRetryError", "transformError"];
4791
+ var _excluded$1 = ["retry", "retryDelay", "onRetryError", "transformError"];
4876
4792
  var Task = /* @__PURE__ */ function() {
4877
4793
  function Task2(type, config) {
4878
4794
  _classCallCheck$1(this, Task2);
@@ -4892,7 +4808,7 @@ var Task = /* @__PURE__ */ function() {
4892
4808
  key: "exec",
4893
4809
  value: function exec() {
4894
4810
  var _this = this;
4895
- var _this$_config = this._config, retry = _this$_config.retry, retryDelay = _this$_config.retryDelay, onRetryError = _this$_config.onRetryError, transformError = _this$_config.transformError, rest = _objectWithoutProperties(_this$_config, _excluded$2);
4811
+ var _this$_config = this._config, retry = _this$_config.retry, retryDelay = _this$_config.retryDelay, onRetryError = _this$_config.onRetryError, transformError = _this$_config.transformError, rest = _objectWithoutProperties(_this$_config, _excluded$1);
4896
4812
  var request = /* @__PURE__ */ function() {
4897
4813
  var _ref = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee() {
4898
4814
  var response, error, isRetry;
@@ -5617,19 +5533,19 @@ function _isNativeReflectConstruct() {
5617
5533
  return false;
5618
5534
  }
5619
5535
  }
5620
- function _assertThisInitialized(self2) {
5621
- if (self2 === void 0) {
5536
+ function _assertThisInitialized(self) {
5537
+ if (self === void 0) {
5622
5538
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5623
5539
  }
5624
- return self2;
5540
+ return self;
5625
5541
  }
5626
- function _possibleConstructorReturn(self2, call) {
5542
+ function _possibleConstructorReturn(self, call) {
5627
5543
  if (call && (typeof call === "object" || typeof call === "function")) {
5628
5544
  return call;
5629
5545
  } else if (call !== void 0) {
5630
5546
  throw new TypeError("Derived constructors may only return object or undefined");
5631
5547
  }
5632
- return _assertThisInitialized(self2);
5548
+ return _assertThisInitialized(self);
5633
5549
  }
5634
5550
  function _createSuper(Derived) {
5635
5551
  var hasNativeReflectConstruct = _isNativeReflectConstruct();
@@ -5688,60 +5604,6 @@ function _nonIterableSpread() {
5688
5604
  function _nonIterableRest() {
5689
5605
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5690
5606
  }
5691
- function _createForOfIteratorHelper(o, allowArrayLike) {
5692
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
5693
- if (!it) {
5694
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
5695
- if (it)
5696
- o = it;
5697
- var i = 0;
5698
- var F = function() {
5699
- };
5700
- return {
5701
- s: F,
5702
- n: function() {
5703
- if (i >= o.length)
5704
- return {
5705
- done: true
5706
- };
5707
- return {
5708
- done: false,
5709
- value: o[i++]
5710
- };
5711
- },
5712
- e: function(e) {
5713
- throw e;
5714
- },
5715
- f: F
5716
- };
5717
- }
5718
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5719
- }
5720
- var normalCompletion = true, didErr = false, err;
5721
- return {
5722
- s: function() {
5723
- it = it.call(o);
5724
- },
5725
- n: function() {
5726
- var step = it.next();
5727
- normalCompletion = step.done;
5728
- return step;
5729
- },
5730
- e: function(e) {
5731
- didErr = true;
5732
- err = e;
5733
- },
5734
- f: function() {
5735
- try {
5736
- if (!normalCompletion && it.return != null)
5737
- it.return();
5738
- } finally {
5739
- if (didErr)
5740
- throw err;
5741
- }
5742
- }
5743
- };
5744
- }
5745
5607
  function _toPrimitive(input, hint) {
5746
5608
  if (typeof input !== "object" || input === null)
5747
5609
  return input;
@@ -5764,15 +5626,13 @@ var TrackType = {
5764
5626
  METADATA: "metadata"
5765
5627
  };
5766
5628
  var VideoCodecType = {
5767
- AV1: "av1",
5768
5629
  AVC: "avc",
5769
5630
  HEVC: "hevc"
5770
5631
  };
5771
5632
  var AudioCodecType = {
5772
5633
  AAC: "aac",
5773
5634
  G711PCMA: "g7110a",
5774
- G711PCMU: "g7110m",
5775
- OPUS: "opus"
5635
+ G711PCMU: "g7110m"
5776
5636
  };
5777
5637
  var WarningType = {
5778
5638
  LARGE_AV_SHIFT: "LARGE_AV_SHIFT",
@@ -5812,7 +5672,6 @@ var VideoTrack = /* @__PURE__ */ function() {
5812
5672
  _defineProperty(this, "isVideoEncryption", false);
5813
5673
  _defineProperty(this, "isAudioEncryption", false);
5814
5674
  _defineProperty(this, "isVideo", true);
5815
- _defineProperty(this, "lastKeyFrameDts", 0);
5816
5675
  _defineProperty(this, "kid", null);
5817
5676
  _defineProperty(this, "pssh", null);
5818
5677
  _defineProperty(this, "ext", void 0);
@@ -5855,9 +5714,6 @@ var VideoTrack = /* @__PURE__ */ function() {
5855
5714
  }, {
5856
5715
  key: "exist",
5857
5716
  value: function exist() {
5858
- if (/av01/.test(this.codec)) {
5859
- return true;
5860
- }
5861
5717
  return !!(this.pps.length && this.sps.length && this.codec);
5862
5718
  }
5863
5719
  }, {
@@ -5921,7 +5777,7 @@ var AudioTrack = /* @__PURE__ */ function() {
5921
5777
  }, {
5922
5778
  key: "exist",
5923
5779
  value: function exist() {
5924
- return !!(this.sampleRate && this.channelCount && this.codec && (this.codecType === AudioCodecType.AAC || this.codecType === AudioCodecType.G711PCMA || this.codecType === AudioCodecType.G711PCMU || this.codecType === AudioCodecType.OPUS));
5780
+ return !!(this.sampleRate && this.channelCount && this.codec && this.codecType === AudioCodecType.AAC);
5925
5781
  }
5926
5782
  }, {
5927
5783
  key: "hasSample",
@@ -6126,7 +5982,7 @@ var AAC = /* @__PURE__ */ function() {
6126
5982
  continue;
6127
5983
  }
6128
5984
  frameLength = (data[i + 3] & 3) << 11 | data[i + 4] << 3 | (data[i + 5] & 224) >> 5;
6129
- if (!frameLength || len - i < frameLength)
5985
+ if (len - i < frameLength)
6130
5986
  break;
6131
5987
  protectionSkipBytes = (~data[i + 1] & 1) * 2;
6132
5988
  frames.push({
@@ -6320,15 +6176,6 @@ function parse2(a) {
6320
6176
  return parseInt(item, 16);
6321
6177
  });
6322
6178
  }
6323
- function combineToFloat(integer, decimal) {
6324
- return Number(integer + "." + decimal);
6325
- }
6326
- function toDegree(matrix) {
6327
- if (matrix.length < 5)
6328
- return 0;
6329
- var scaled0 = Math.hypot(matrix[0], matrix[3]), scaled1 = Math.hypot(matrix[1], matrix[4]);
6330
- return 0 === scaled0 || 0 === scaled1 ? 0 : 180 * Math.atan2(matrix[1] / scaled1, matrix[0] / scaled0) / Math.PI;
6331
- }
6332
6179
  var NALu = /* @__PURE__ */ function() {
6333
6180
  function NALu2() {
6334
6181
  _classCallCheck(this, NALu2);
@@ -6991,16 +6838,13 @@ var MAX_SILENT_FRAME_DURATION = 9e4;
6991
6838
  var AUDIO_EXCETION_LOG_EMIT_DURATION = 5 * 9e4;
6992
6839
  var MAX_VIDEO_FRAME_DURATION = 9e4;
6993
6840
  var MAX_DTS_DELTA_WITH_NEXT_CHUNK = 9e4 / 2;
6994
- var LARGE_AV_FIRST_FRAME_FORCE_FIX_THRESHOLD = 9e4 * 5;
6995
6841
  var TsFixer = /* @__PURE__ */ function() {
6996
- function TsFixer2(videoTrack, audioTrack, metadataTrack, fixerConfig) {
6842
+ function TsFixer2(videoTrack, audioTrack, metadataTrack) {
6997
6843
  _classCallCheck(this, TsFixer2);
6998
6844
  this.videoTrack = videoTrack;
6999
6845
  this.audioTrack = audioTrack;
7000
6846
  this.metadataTrack = metadataTrack;
7001
6847
  this._baseDts = -1;
7002
- this._baseVideoDts = -1;
7003
- this._baseAudioDts = -1;
7004
6848
  this._baseDtsInited = false;
7005
6849
  this._audioNextPts = void 0;
7006
6850
  this._videoNextDts = void 0;
@@ -7009,8 +6853,6 @@ var TsFixer = /* @__PURE__ */ function() {
7009
6853
  this._lastAudioExceptionGapDot = 0;
7010
6854
  this._lastAudioExceptionOverlapDot = 0;
7011
6855
  this._lastAudioExceptionLargeGapDot = 0;
7012
- this._needForceFixLargeGap = fixerConfig === null || fixerConfig === void 0 ? void 0 : fixerConfig.forceFixLargeGap;
7013
- this._largeGapThreshold = (fixerConfig === null || fixerConfig === void 0 ? void 0 : fixerConfig.largeGapThreshold) || LARGE_AV_FIRST_FRAME_FORCE_FIX_THRESHOLD;
7014
6856
  }
7015
6857
  _createClass(TsFixer2, [{
7016
6858
  key: "fix",
@@ -7038,16 +6880,10 @@ var TsFixer = /* @__PURE__ */ function() {
7038
6880
  if (discontinuity) {
7039
6881
  this._calculateBaseDts(this.audioTrack, this.videoTrack);
7040
6882
  this._baseDts -= startTime;
7041
- this._baseAudioDts -= startTime;
7042
- this._baseVideoDts -= startTime;
7043
6883
  }
7044
6884
  if (!contiguous) {
7045
6885
  this._videoNextDts = vaDelta > 0 ? startTime + vaDelta : startTime;
7046
6886
  this._audioNextPts = vaDelta > 0 ? startTime : startTime - vaDelta;
7047
- if (this._needForceFixLargeGap) {
7048
- this._videoNextDts = 0;
7049
- this._audioNextPts = 0;
7050
- }
7051
6887
  var vDeltaToNextDts = firstVideoSample ? firstVideoSample.dts - this._baseDts - this._videoNextDts : 0;
7052
6888
  var aDeltaToNextDts = firstAudioSample ? firstAudioSample.pts - this._baseDts - this._audioNextPts : 0;
7053
6889
  if (Math.abs(vDeltaToNextDts || aDeltaToNextDts) > MAX_VIDEO_FRAME_DURATION) {
@@ -7080,8 +6916,8 @@ var TsFixer = /* @__PURE__ */ function() {
7080
6916
  if (!samples.length)
7081
6917
  return;
7082
6918
  samples.forEach(function(x) {
7083
- x.dts -= _this2._needForceFixLargeGap ? _this2._baseVideoDts : _this2._baseDts;
7084
- x.pts -= _this2._needForceFixLargeGap ? _this2._baseVideoDts : _this2._baseDts;
6919
+ x.dts -= _this2._baseDts;
6920
+ x.pts -= _this2._baseDts;
7085
6921
  });
7086
6922
  if (this._videoNextDts === void 0) {
7087
6923
  var samp0 = samples[0];
@@ -7174,7 +7010,7 @@ var TsFixer = /* @__PURE__ */ function() {
7174
7010
  if (!samples.length)
7175
7011
  return;
7176
7012
  samples.forEach(function(x) {
7177
- x.pts -= _this3._needForceFixLargeGap ? _this3._baseAudioDts : _this3._baseDts;
7013
+ x.pts -= _this3._baseDts;
7178
7014
  x.dts = x.pts;
7179
7015
  });
7180
7016
  this._doFixAudioInternal(audioTrack, samples, 9e4);
@@ -7191,15 +7027,12 @@ var TsFixer = /* @__PURE__ */ function() {
7191
7027
  var videoBaseDts = Infinity;
7192
7028
  if (audioSamps.length) {
7193
7029
  audioTrack.baseDts = audioBasePts = audioSamps[0].pts;
7194
- this._baseAudioDts = audioBasePts;
7195
7030
  }
7196
7031
  if (videoSamps.length) {
7197
7032
  videoTrack.baseDts = videoBaseDts = videoSamps[0].dts;
7198
- this._baseVideoDts = videoBaseDts;
7199
7033
  }
7200
7034
  this._baseDts = Math.min(audioBasePts, videoBaseDts);
7201
7035
  var delta = videoBaseDts - audioBasePts;
7202
- var largeGap = false;
7203
7036
  if (Number.isFinite(delta) && Math.abs(delta) > LARGE_AV_FIRST_FRAME_GAP) {
7204
7037
  videoTrack.warnings.push({
7205
7038
  type: WarningType.LARGE_AV_SHIFT,
@@ -7209,16 +7042,6 @@ var TsFixer = /* @__PURE__ */ function() {
7209
7042
  delta
7210
7043
  });
7211
7044
  }
7212
- if (Number.isFinite(delta) && Math.abs(delta) > this._largeGapThreshold * MAX_SILENT_FRAME_DURATION) {
7213
- largeGap = true;
7214
- }
7215
- if (!this._baseDtsInited) {
7216
- if (largeGap && this._needForceFixLargeGap) {
7217
- this._needForceFixLargeGap = true;
7218
- } else {
7219
- this._needForceFixLargeGap = false;
7220
- }
7221
- }
7222
7045
  this._baseDtsInited = true;
7223
7046
  return true;
7224
7047
  }
@@ -7312,7 +7135,6 @@ var TsFixer = /* @__PURE__ */ function() {
7312
7135
  var logger$4 = new Logger$1("TsDemuxer");
7313
7136
  var TsDemuxer = /* @__PURE__ */ function() {
7314
7137
  function TsDemuxer2(videoTrack, audioTrack, metadataTrack) {
7315
- var fixerConfig = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
7316
7138
  _classCallCheck(this, TsDemuxer2);
7317
7139
  _defineProperty(this, "_pmtId", -1);
7318
7140
  _defineProperty(this, "_remainingPacketData", null);
@@ -7322,7 +7144,7 @@ var TsDemuxer = /* @__PURE__ */ function() {
7322
7144
  this.videoTrack = videoTrack || new VideoTrack();
7323
7145
  this.audioTrack = audioTrack || new AudioTrack();
7324
7146
  this.metadataTrack = metadataTrack || new MetadataTrack();
7325
- this._fixer = new TsFixer(this.videoTrack, this.audioTrack, this.metadataTrack, fixerConfig);
7147
+ this._fixer = new TsFixer(this.videoTrack, this.audioTrack, this.metadataTrack);
7326
7148
  }
7327
7149
  _createClass(TsDemuxer2, [{
7328
7150
  key: "demux",
@@ -7669,207 +7491,6 @@ var TsDemuxer = /* @__PURE__ */ function() {
7669
7491
  }]);
7670
7492
  return TsDemuxer2;
7671
7493
  }();
7672
- var ByteReader = /* @__PURE__ */ function() {
7673
- function ByteReader2(buf, offset, len) {
7674
- _classCallCheck(this, ByteReader2);
7675
- this.dv = new DataView(buf);
7676
- this.start = this.offset = offset || this.dv.byteOffset;
7677
- this.end = len ? this.start + len : this.start + this.dv.byteLength;
7678
- }
7679
- _createClass(ByteReader2, [{
7680
- key: "buffer",
7681
- get: function get() {
7682
- return this.dv.buffer;
7683
- }
7684
- }, {
7685
- key: "unreadLength",
7686
- get: function get() {
7687
- return Math.max(this.end - this.offset, 0);
7688
- }
7689
- }, {
7690
- key: "size",
7691
- get: function get() {
7692
- return this.end - this.start;
7693
- }
7694
- }, {
7695
- key: "readFloat",
7696
- value: function readFloat(byteNum) {
7697
- var val = 0;
7698
- switch (byteNum) {
7699
- case 4:
7700
- val = this.dv.getFloat32(this.offset);
7701
- break;
7702
- case 8:
7703
- val = this.dv.getFloat64(this.offset);
7704
- break;
7705
- default:
7706
- throw new Error("read ".concat(byteNum, "-byte float is not supported"));
7707
- }
7708
- this.offset += byteNum;
7709
- return val;
7710
- }
7711
- }, {
7712
- key: "back",
7713
- value: function back(byteNum) {
7714
- this.offset -= byteNum;
7715
- }
7716
- }, {
7717
- key: "skip",
7718
- value: function skip(byteNum) {
7719
- this.offset += byteNum;
7720
- }
7721
- }, {
7722
- key: "readInt",
7723
- value: function readInt(byteNum) {
7724
- var offset = this.offset;
7725
- this.offset += byteNum;
7726
- switch (byteNum) {
7727
- case 1:
7728
- return this.dv.getInt8(offset);
7729
- case 2:
7730
- return this.dv.getInt16(offset);
7731
- case 4:
7732
- return this.dv.getInt32(offset);
7733
- default:
7734
- throw new Error("read ".concat(byteNum, "-byte integers is not supported"));
7735
- }
7736
- }
7737
- }, {
7738
- key: "read",
7739
- value: function read(byteNum) {
7740
- var offset = this.offset;
7741
- this.offset += byteNum;
7742
- switch (byteNum) {
7743
- case 1:
7744
- return this.dv.getUint8(offset);
7745
- case 2:
7746
- return this.dv.getUint16(offset);
7747
- case 3:
7748
- return (this.dv.getUint16(offset) << 8) + this.dv.getUint8(offset + 2);
7749
- case 4:
7750
- return this.dv.getUint32(offset);
7751
- default:
7752
- this.back(byteNum - 4);
7753
- return this.read(byteNum - 4) + this.dv.getUint32(offset) * Math.pow(256, byteNum - 4);
7754
- }
7755
- }
7756
- }, {
7757
- key: "write",
7758
- value: function write(byteNum, val) {
7759
- var offset = this.offset;
7760
- this.offset += byteNum;
7761
- switch (byteNum) {
7762
- case 1:
7763
- return this.dv.setUint8(offset, val);
7764
- case 2:
7765
- return this.dv.setUint16(offset, val);
7766
- case 3:
7767
- return this.dv.setUint8(offset, val >>> 16), this.dv.setUint16(offset + 1, 65535 & val);
7768
- case 4:
7769
- return this.dv.setUint32(offset, val);
7770
- default:
7771
- throw new Error("write ".concat(byteNum, "-byte integers is not supported"));
7772
- }
7773
- }
7774
- }, {
7775
- key: "readToBuffer",
7776
- value: function readToBuffer(len) {
7777
- var buffer;
7778
- if (this.offset || len) {
7779
- buffer = this.dv.buffer.slice(this.offset, len ? this.offset + len : this.end);
7780
- } else {
7781
- buffer = this.dv.buffer;
7782
- }
7783
- this.offset += buffer.byteLength;
7784
- return buffer;
7785
- }
7786
- }, {
7787
- key: "readToUint8",
7788
- value: function readToUint8(len) {
7789
- var uint8 = new Uint8Array(this.dv.buffer, this.offset, len || this.unreadLength);
7790
- this.offset += uint8.byteLength;
7791
- return uint8;
7792
- }
7793
- }, {
7794
- key: "readString",
7795
- value: function readString(len) {
7796
- var i = 0, str = "";
7797
- for (; i < len; i++) {
7798
- str += String.fromCharCode(this.dv.getUint8(this.offset));
7799
- this.offset++;
7800
- }
7801
- return str;
7802
- }
7803
- }], [{
7804
- key: "fromUint8",
7805
- value: function fromUint8(uint8) {
7806
- return new ByteReader2(uint8.buffer, uint8.byteOffset, uint8.byteLength);
7807
- }
7808
- }, {
7809
- key: "concatUint8s",
7810
- value: function concatUint8s(args) {
7811
- var uint8 = new Uint8Array(args.reduce(function(ret, v) {
7812
- return ret + v.byteLength;
7813
- }, 0));
7814
- var offset = 0;
7815
- args.forEach(function(v) {
7816
- uint8.set(v, offset);
7817
- offset += v.byteLength;
7818
- });
7819
- return uint8;
7820
- }
7821
- }, {
7822
- key: "concatUint8",
7823
- value: function concatUint8() {
7824
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
7825
- args[_key] = arguments[_key];
7826
- }
7827
- return this.concatUint8s(args);
7828
- }
7829
- }]);
7830
- return ByteReader2;
7831
- }();
7832
- var BitReader = /* @__PURE__ */ function() {
7833
- function BitReader2(val, size) {
7834
- _classCallCheck(this, BitReader2);
7835
- this.offset = 0;
7836
- this.val = val;
7837
- this.size = size;
7838
- }
7839
- _createClass(BitReader2, [{
7840
- key: "skip",
7841
- value: function skip(len) {
7842
- this.offset += len;
7843
- }
7844
- }, {
7845
- key: "read",
7846
- value: function read(len) {
7847
- var unreadLength = this.size - this.offset - len;
7848
- if (unreadLength >= 0) {
7849
- var bits = 0, i = 0;
7850
- this.offset += len;
7851
- if (this.size > 31) {
7852
- for (; i < len; i++) {
7853
- bits += Math.pow(2, i);
7854
- }
7855
- return this.val / Math.pow(2, unreadLength) & bits;
7856
- } else {
7857
- for (; i < len; i++) {
7858
- bits += 1 << i;
7859
- }
7860
- return this.val >>> unreadLength & bits;
7861
- }
7862
- }
7863
- throw new Error("the number of the read operation exceeds the total length limit of bits");
7864
- }
7865
- }], [{
7866
- key: "fromByte",
7867
- value: function fromByte(byte, len) {
7868
- return new BitReader2(byte.read(len), len << 3);
7869
- }
7870
- }]);
7871
- return BitReader2;
7872
- }();
7873
7494
  var MP4Parser = /* @__PURE__ */ function() {
7874
7495
  function MP4Parser2() {
7875
7496
  _classCallCheck(this, MP4Parser2);
@@ -8027,36 +7648,18 @@ var MP4Parser = /* @__PURE__ */ function() {
8027
7648
  key: "tkhd",
8028
7649
  value: function tkhd(box) {
8029
7650
  return parseBox(box, true, function(ret, data) {
8030
- var byte = ByteReader.fromUint8(data);
7651
+ var start = 0;
8031
7652
  if (ret.version === 1) {
8032
- byte.read(8);
8033
- byte.read(8);
8034
- ret.trackId = byte.read(4);
8035
- byte.read(4);
8036
- ret.duration = byte.read(8);
7653
+ ret.trackId = readBig32(data, 16);
7654
+ ret.duration = readBig64(data, 24);
7655
+ start += 32;
8037
7656
  } else {
8038
- byte.read(4);
8039
- byte.read(4);
8040
- ret.trackId = byte.read(4);
8041
- byte.read(4);
8042
- ret.duration = byte.read(4);
7657
+ ret.trackId = readBig32(data, 8);
7658
+ ret.duration = readBig32(data, 16);
7659
+ start += 20;
8043
7660
  }
8044
- byte.skip(16);
8045
- ret.matrix = [];
8046
- for (var i = 0; i < 36; i++) {
8047
- ret.matrix.push(byte.read(1));
8048
- }
8049
- byte.back(36);
8050
- var caculatedMatrix = [];
8051
- for (var _i = 0, int32; _i < 3; _i++) {
8052
- caculatedMatrix.push(combineToFloat(byte.readInt(2), byte.readInt(2)));
8053
- caculatedMatrix.push(combineToFloat(byte.readInt(2), byte.readInt(2)));
8054
- int32 = byte.readInt(4);
8055
- caculatedMatrix.push(combineToFloat(int32 >> 30, int32 & 1073741823));
8056
- }
8057
- ret.rotation = toDegree(caculatedMatrix);
8058
- ret.width = byte.read(4);
8059
- ret.height = byte.read(4);
7661
+ ret.width = readBig32(data, start + 52);
7662
+ ret.height = readBig32(data, start + 56);
8060
7663
  });
8061
7664
  }
8062
7665
  }, {
@@ -8186,7 +7789,7 @@ var MP4Parser = /* @__PURE__ */ function() {
8186
7789
  if (ret.version > 0) {
8187
7790
  var numKeyIds = readBig32(data, start);
8188
7791
  start += 4;
8189
- for (var _i2 = 0; _i2 < ("" + numKeyIds).length; _i2++) {
7792
+ for (var _i = 0; _i < ("" + numKeyIds).length; _i++) {
8190
7793
  for (var j = 0; j < 16; j++) {
8191
7794
  var keyId = data[start];
8192
7795
  start += 1;
@@ -8209,8 +7812,6 @@ var MP4Parser = /* @__PURE__ */ function() {
8209
7812
  ret.entryCount = readBig32(data);
8210
7813
  ret.entries = MP4Parser2.findBox(data.subarray(4), [], start + 4).map(function(b) {
8211
7814
  switch (b.type) {
8212
- case "av01":
8213
- return MP4Parser2.av01(b);
8214
7815
  case "avc1":
8215
7816
  case "avc2":
8216
7817
  case "avc3":
@@ -8290,69 +7891,6 @@ var MP4Parser = /* @__PURE__ */ function() {
8290
7891
  }
8291
7892
  });
8292
7893
  }
8293
- }, {
8294
- key: "colr",
8295
- value: function colr(box) {
8296
- return parseBox(box, false, function(ret, data) {
8297
- var byte = ByteReader.fromUint8(data);
8298
- ret.data = box.data;
8299
- ret.colorType = byte.readString(4);
8300
- if (ret.colorType === "nclx") {
8301
- ret.colorPrimaries = byte.read(2);
8302
- ret.transferCharacteristics = byte.read(2);
8303
- ret.matrixCoefficients = byte.read(2);
8304
- ret.fullRangeFlag = byte.read(1) >> 7;
8305
- } else if (ret.colorType === "rICC" || ret.colorType === "prof") {
8306
- ret.iccProfile = data.readToUint8();
8307
- }
8308
- });
8309
- }
8310
- }, {
8311
- key: "av01",
8312
- value: function av01(box) {
8313
- return parseBox(box, false, function(ret, data, start) {
8314
- var bodyStart = parseVisualSampleEntry(ret, data);
8315
- var bodyData = data.subarray(bodyStart);
8316
- start += bodyStart;
8317
- ret.av1C = MP4Parser2.av1C(MP4Parser2.findBox(bodyData, ["av1C"], start)[0]);
8318
- ret.colr = MP4Parser2.colr(MP4Parser2.findBox(bodyData, ["colr"], start)[0]);
8319
- });
8320
- }
8321
- }, {
8322
- key: "av1C",
8323
- value: function av1C(box) {
8324
- return parseBox(box, false, function(ret, data) {
8325
- ret.data = box.data;
8326
- var byte = ByteReader.fromUint8(data);
8327
- var bit = BitReader.fromByte(byte, 4);
8328
- ret.marker = bit.read(1);
8329
- ret.version = bit.read(7);
8330
- ret.seqProfile = bit.read(3);
8331
- ret.seqLevelIdx0 = bit.read(5);
8332
- ret.seqTier0 = bit.read(1);
8333
- ret.highBitdepth = bit.read(1);
8334
- ret.twelveBit = bit.read(1);
8335
- ret.monochrome = bit.read(1);
8336
- ret.chromaSubsamplingX = bit.read(1);
8337
- ret.chromaSubsamplingY = bit.read(1);
8338
- ret.chromaSamplePosition = bit.read(2);
8339
- ret.reserved = bit.read(3);
8340
- ret.initialPresentationDelayPresent = bit.read(1);
8341
- if (ret.initialPresentationDelayPresent) {
8342
- ret.initialPresentationDelayMinusOne = bit.read(4);
8343
- } else {
8344
- ret.initialPresentationDelayMinusOne = 0;
8345
- }
8346
- ret.configOBUs = byte.readToUint8();
8347
- var bitdepth;
8348
- if (ret.seqLevelIdx0 === 2 && ret.highBitdepth === 1) {
8349
- bitdepth = ret.twelveBit === 1 ? "12" : "10";
8350
- } else if (ret.seqProfile <= 2) {
8351
- bitdepth = ret.highBitdepth === 1 ? "10" : "08";
8352
- }
8353
- ret.codec = ["av01", ret.seqProfile, (ret.seqLevelIdx0 < 10 ? "0" + ret.seqLevelIdx0 : ret.seqLevelIdx0) + (ret.seqTier0 ? "H" : "M"), bitdepth].join(".");
8354
- });
8355
- }
8356
7894
  }, {
8357
7895
  key: "avc1",
8358
7896
  value: function avc1(box) {
@@ -8387,7 +7925,7 @@ var MP4Parser = /* @__PURE__ */ function() {
8387
7925
  ret.ppsLength = data[start];
8388
7926
  start += 1;
8389
7927
  ret.pps = [];
8390
- for (var _i3 = 0; _i3 < ret.ppsLength; _i3++) {
7928
+ for (var _i2 = 0; _i2 < ret.ppsLength; _i2++) {
8391
7929
  var _size = readBig16(data, start);
8392
7930
  start += 2;
8393
7931
  ret.pps.push(data.subarray(start, start += _size));
@@ -8556,7 +8094,7 @@ var MP4Parser = /* @__PURE__ */ function() {
8556
8094
  start += 8;
8557
8095
  }
8558
8096
  } else {
8559
- for (var _i4 = 0; _i4 < entryCount; _i4++) {
8097
+ for (var _i3 = 0; _i3 < entryCount; _i3++) {
8560
8098
  entries.push({
8561
8099
  count: readBig32(data, start),
8562
8100
  offset: -(~readBig32(data, start + 4) + 1)
@@ -8778,20 +8316,13 @@ var MP4Parser = /* @__PURE__ */ function() {
8778
8316
  v.mvhdTimecale = moov.mvhd.timescale;
8779
8317
  v.timescale = v.formatTimescale = vTrack.mdia.mdhd.timescale;
8780
8318
  v.duration = vTrack.mdia.mdhd.duration || v.mvhdDurtion / v.mvhdTimecale * v.timescale;
8781
- v.rotation = vTrack.tkhd.rotation;
8782
- v.matrix = vTrack.tkhd.matrix;
8783
8319
  var e1 = vTrack.mdia.minf.stbl.stsd.entries[0];
8784
8320
  v.width = e1.width;
8785
8321
  v.height = e1.height;
8786
8322
  if (e1.pasp) {
8787
8323
  v.sarRatio = [e1.pasp.hSpacing, e1.pasp.vSpacing];
8788
8324
  }
8789
- if (e1.av1C) {
8790
- v.codecType = VideoCodecType.AV1;
8791
- v.codec = e1.av1C.codec;
8792
- v.av1C = e1.av1C.data;
8793
- v.colr = e1.colr.data;
8794
- } else if (e1.hvcC) {
8325
+ if (e1.hvcC) {
8795
8326
  v.codecType = VideoCodecType.HEVC;
8796
8327
  v.codec = e1.hvcC.codec;
8797
8328
  v.vps = e1.hvcC.vps;
@@ -9110,9 +8641,8 @@ function parseAudioSampleEntry(ret, data) {
9110
8641
  function parseBox(box, isFullBox, parse3) {
9111
8642
  if (!box)
9112
8643
  return;
9113
- if (box.size !== box.data.length) {
8644
+ if (box.size !== box.data.length)
9114
8645
  throw new Error("box ".concat(box.type, " size !== data.length"));
9115
- }
9116
8646
  var ret = {
9117
8647
  start: box.start,
9118
8648
  size: box.size,
@@ -9151,167 +8681,11 @@ var toHex = function toHex2() {
9151
8681
  var FMP4Demuxer = /* @__PURE__ */ function() {
9152
8682
  function FMP4Demuxer2(videoTrack, audioTrack, metadataTrack) {
9153
8683
  _classCallCheck(this, FMP4Demuxer2);
9154
- _defineProperty(this, "__loadedMoofWraps", []);
9155
- _defineProperty(this, "__lastRemainData", null);
9156
- _defineProperty(this, "__lastRemainDataStart", 0);
9157
- _defineProperty(this, "__nextMoofStart", -1);
9158
8684
  this.videoTrack = videoTrack || new VideoTrack();
9159
8685
  this.audioTrack = audioTrack || new AudioTrack();
9160
8686
  this.metadataTrack = metadataTrack || new MetadataTrack();
9161
8687
  }
9162
8688
  _createClass(FMP4Demuxer2, [{
9163
- key: "demuxPart",
9164
- value: function demuxPart(partData, partDataStart, moov) {
9165
- var _this = this;
9166
- var videoTrack = this.videoTrack, audioTrack = this.audioTrack;
9167
- var videoExist = videoTrack.exist();
9168
- var audioExist = audioTrack.exist();
9169
- var isAV01 = /av01/.test(videoTrack.codec);
9170
- videoTrack.samples = [];
9171
- audioTrack.samples = [];
9172
- var data = partData;
9173
- var dataStart = partDataStart;
9174
- if (this.__lastRemainData) {
9175
- var lastRemainDataEnd = this.__lastRemainDataStart + this.__lastRemainData.byteLength;
9176
- var continuous = partDataStart <= lastRemainDataEnd && partDataStart > this.__lastRemainDataStart && partDataStart + partData.byteLength > lastRemainDataEnd;
9177
- if (continuous) {
9178
- var noDuplicateData = partData.subarray(this.__lastRemainData.byteLength + this.__lastRemainDataStart - partDataStart);
9179
- data = concatUint8Array(this.__lastRemainData, noDuplicateData);
9180
- dataStart = this.__lastRemainDataStart;
9181
- this.__lastRemainData = null;
9182
- } else {
9183
- this.__lastRemainData = null;
9184
- this.__lastRemainDataStart = 0;
9185
- this.__nextMoofStart = -1;
9186
- }
9187
- }
9188
- if (!moov) {
9189
- var moovBox = MP4Parser.findBox(data, ["moov"])[0];
9190
- if (!moovBox)
9191
- throw new Error("cannot found moov box");
9192
- moov = MP4Parser.moov(moovBox);
9193
- }
9194
- if (data) {
9195
- var dataEnd = dataStart + data.byteLength;
9196
- if (!videoExist && !audioExist) {
9197
- MP4Parser.moovToTrack(moov, videoTrack, audioTrack);
9198
- }
9199
- var moofBoxes = [];
9200
- if (this.__nextMoofStart < 0) {
9201
- MP4Parser.findBox(data, ["moof"], dataStart).forEach(function(v) {
9202
- return moofBoxes.push(v);
9203
- });
9204
- } else if (this.__nextMoofStart >= dataStart && this.__nextMoofStart <= dataEnd - 8) {
9205
- MP4Parser.findBox(data.subarray(this.__nextMoofStart - dataStart), ["moof"], this.__nextMoofStart).forEach(function(v) {
9206
- return moofBoxes.push(v);
9207
- });
9208
- }
9209
- moofBoxes.filter(function(moofBox) {
9210
- return moofBox.size <= moofBox.data.length;
9211
- }).forEach(function(moofBox) {
9212
- var moof = MP4Parser.moof(moofBox);
9213
- _this.__nextMoofStart = moof.start + Math.max.apply(Math, _toConsumableArray(moof.traf.map(function(v) {
9214
- return v.trun.samples.reduce(function(ret, w) {
9215
- return ret + w.size;
9216
- }, v.trun.dataOffset || 0);
9217
- })));
9218
- _this.__loadedMoofWraps.push({
9219
- start: moof.start,
9220
- nextMoofStart: _this.__nextMoofStart,
9221
- moof
9222
- });
9223
- _this.__loadedMoofWraps.sort(function(p, n) {
9224
- return p.start - n.start;
9225
- });
9226
- });
9227
- var _iterator = _createForOfIteratorHelper(this.__loadedMoofWraps), _step;
9228
- try {
9229
- var _loop = function _loop2() {
9230
- var moofWrap = _step.value;
9231
- if (moofWrap.start > dataEnd || moofWrap.nextMoofStart < dataStart) {
9232
- return "continue";
9233
- }
9234
- var moofStart = moofWrap.start;
9235
- var tracks = MP4Parser.moofToSamples(moofWrap.moof, videoTrack, audioTrack);
9236
- var videoBaseMediaDecodeTime = videoTrack.baseMediaDecodeTime;
9237
- var audioBaseMediaDecodeTime = audioTrack.baseMediaDecodeTime;
9238
- var nalSize;
9239
- Object.keys(tracks).forEach(function(k) {
9240
- if (videoTrack.id == k) {
9241
- tracks[k].some(function(x) {
9242
- var xStart = x.offset += moofStart;
9243
- if (xStart < dataStart) {
9244
- return;
9245
- }
9246
- if (xStart + x.size > dataEnd) {
9247
- return true;
9248
- }
9249
- var sample = new VideoSample((x.pts || x.dts) + videoBaseMediaDecodeTime, x.dts + videoBaseMediaDecodeTime);
9250
- sample.duration = x.duration;
9251
- sample.gopId = x.gopId;
9252
- if (x.keyframe)
9253
- sample.setToKeyframe();
9254
- var sampleData = data.subarray(xStart - dataStart, xStart - dataStart + x.size);
9255
- sample.data = sampleData;
9256
- if (!isAV01) {
9257
- var start = 0;
9258
- var len = sampleData.length - 1;
9259
- while (start < len) {
9260
- nalSize = readBig32(sampleData, start);
9261
- start += 4;
9262
- sample.units.push(sampleData.subarray(start, start + nalSize));
9263
- start += nalSize;
9264
- }
9265
- }
9266
- _this.__lastRemainDataStart = xStart + x.size;
9267
- videoTrack.samples.push(sample);
9268
- });
9269
- } else if (audioTrack.id == k) {
9270
- tracks[k].some(function(x) {
9271
- var xStart = x.offset + moofStart;
9272
- if (xStart < dataStart) {
9273
- return;
9274
- }
9275
- if (xStart + x.size > dataEnd) {
9276
- return true;
9277
- }
9278
- var sampleData = data.subarray(xStart - dataStart, xStart - dataStart + x.size);
9279
- audioTrack.samples.push(new AudioSample(x.dts + audioBaseMediaDecodeTime, sampleData, x.duration));
9280
- _this.__lastRemainDataStart = xStart + x.size;
9281
- });
9282
- }
9283
- });
9284
- };
9285
- for (_iterator.s(); !(_step = _iterator.n()).done; ) {
9286
- var _ret = _loop();
9287
- if (_ret === "continue")
9288
- continue;
9289
- }
9290
- } catch (err) {
9291
- _iterator.e(err);
9292
- } finally {
9293
- _iterator.f();
9294
- }
9295
- }
9296
- if (this.__lastRemainDataStart > dataStart && this.__lastRemainDataStart < data.byteLength + dataStart) {
9297
- this.__lastRemainData = data.subarray(this.__lastRemainDataStart - dataStart);
9298
- } else {
9299
- this.__lastRemainData = data;
9300
- this.__lastRemainDataStart = dataStart;
9301
- }
9302
- if (videoTrack.samples.length) {
9303
- videoTrack.baseMediaDecodeTime = videoTrack.samples[0].pts;
9304
- }
9305
- if (audioTrack.samples.length) {
9306
- audioTrack.baseMediaDecodeTime = audioTrack.samples[0].pts;
9307
- }
9308
- return {
9309
- videoTrack,
9310
- audioTrack,
9311
- metadataTrack: this.metadataTrack
9312
- };
9313
- }
9314
- }, {
9315
8689
  key: "demux",
9316
8690
  value: function demux(videoData, audioData) {
9317
8691
  var videoTrack = this.videoTrack, audioTrack = this.audioTrack;
@@ -9430,13 +8804,13 @@ var Buffer = /* @__PURE__ */ function() {
9430
8804
  _createClass(Buffer2, [{
9431
8805
  key: "write",
9432
8806
  value: function write() {
9433
- var self2 = this;
8807
+ var self = this;
9434
8808
  for (var _len2 = arguments.length, buffer = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
9435
8809
  buffer[_key2] = arguments[_key2];
9436
8810
  }
9437
8811
  buffer.forEach(function(item) {
9438
8812
  if (item) {
9439
- self2.buffer = Concat(Uint8Array, self2.buffer, item);
8813
+ self.buffer = Concat(Uint8Array, self.buffer, item);
9440
8814
  } else {
9441
8815
  window.console.warn(item);
9442
8816
  }
@@ -9803,16 +9177,10 @@ var MP4 = /* @__PURE__ */ function() {
9803
9177
  if (track.useEME && track.enca) {
9804
9178
  content = MP42.enca(track);
9805
9179
  } else {
9806
- if (track.codecType === AudioCodecType.OPUS) {
9807
- content = MP42.opus(track);
9808
- } else {
9809
- content = MP42.mp4a(track);
9810
- }
9180
+ content = MP42.mp4a(track);
9811
9181
  }
9812
9182
  } else if (track.useEME && track.encv) {
9813
9183
  content = MP42.encv(track);
9814
- } else if (track.av1C) {
9815
- content = MP42.av01(track);
9816
9184
  } else {
9817
9185
  content = MP42.avc1hev1(track);
9818
9186
  }
@@ -10026,96 +9394,12 @@ var MP4 = /* @__PURE__ */ function() {
10026
9394
  return MP42.box(MP42.types.sinf, content, MP42.box(MP42.types.frma, frma), MP42.box(MP42.types.schm, schm), schi);
10027
9395
  }
10028
9396
  }, {
10029
- key: "av01",
10030
- value: function av01(track) {
10031
- return MP42.box(MP42.types.av01, new Uint8Array([
10032
- 0,
10033
- 0,
10034
- 0,
10035
- 0,
10036
- 0,
10037
- 0,
10038
- 0,
10039
- 1,
10040
- 0,
10041
- 0,
10042
- 0,
10043
- 0,
10044
- 0,
10045
- 0,
10046
- 0,
10047
- 0,
10048
- 0,
10049
- 0,
10050
- 0,
10051
- 0,
10052
- 0,
10053
- 0,
10054
- 0,
10055
- 0,
10056
- track.width >> 8 & 255,
10057
- track.width & 255,
10058
- track.height >> 8 & 255,
10059
- track.height & 255,
10060
- 0,
10061
- 72,
10062
- 0,
10063
- 0,
10064
- 0,
10065
- 72,
10066
- 0,
10067
- 0,
10068
- 0,
10069
- 0,
10070
- 0,
10071
- 0,
10072
- 0,
10073
- 1,
10074
- 0,
10075
- 0,
10076
- 0,
10077
- 0,
10078
- 0,
10079
- 0,
10080
- 0,
10081
- 0,
10082
- 0,
10083
- 0,
10084
- 0,
10085
- 0,
10086
- 0,
10087
- 0,
10088
- 0,
10089
- 0,
10090
- 0,
10091
- 0,
10092
- 0,
10093
- 0,
10094
- 0,
10095
- 0,
10096
- 0,
10097
- 0,
10098
- 0,
10099
- 0,
10100
- 0,
10101
- 0,
10102
- 0,
10103
- 0,
10104
- 0,
10105
- 0,
10106
- 0,
10107
- 24,
10108
- 17,
10109
- 17
10110
- ]), track.av1C, track.colr);
10111
- }
10112
- }, {
10113
- key: "avc1hev1",
10114
- value: function avc1hev1(track) {
10115
- var isHevc = track.codecType === VideoCodecType.HEVC;
10116
- var typ = isHevc ? MP42.types.hvc1 : MP42.types.avc1;
10117
- var config = isHevc ? MP42.hvcC(track) : MP42.avcC(track);
10118
- var boxes = [new Uint8Array([
9397
+ key: "avc1hev1",
9398
+ value: function avc1hev1(track) {
9399
+ var isHevc = track.codecType === VideoCodecType.HEVC;
9400
+ var typ = isHevc ? MP42.types.hvc1 : MP42.types.avc1;
9401
+ var config = isHevc ? MP42.hvcC(track) : MP42.avcC(track);
9402
+ var boxes = [new Uint8Array([
10119
9403
  0,
10120
9404
  0,
10121
9405
  0,
@@ -10479,53 +9763,6 @@ var MP4 = /* @__PURE__ */ function() {
10479
9763
  )));
10480
9764
  return esds2;
10481
9765
  }
10482
- }, {
10483
- key: "opus",
10484
- value: function opus(track) {
10485
- var opusAudioDescription = new Uint8Array([
10486
- 0,
10487
- 0,
10488
- 0,
10489
- 0,
10490
- 0,
10491
- 0,
10492
- 0,
10493
- 1,
10494
- 0,
10495
- 0,
10496
- 0,
10497
- 0,
10498
- 0,
10499
- 0,
10500
- 0,
10501
- 0,
10502
- 0,
10503
- track.channelCount,
10504
- 0,
10505
- 16,
10506
- 0,
10507
- 0,
10508
- 0,
10509
- 0,
10510
- track.sampleRate >> 8 & 255,
10511
- track.sampleRate & 255,
10512
- 0,
10513
- 0
10514
- ]);
10515
- var opusSpecificConfig = track.config.length ? MP42.dOps(track) : [];
10516
- return MP42.box(MP42.types.Opus, opusAudioDescription, opusSpecificConfig);
10517
- }
10518
- }, {
10519
- key: "dOps",
10520
- value: function dOps(track) {
10521
- if (track.config) {
10522
- track.config[4] = track.sampleRate >>> 24 & 255;
10523
- track.config[5] = track.sampleRate >>> 16 & 255;
10524
- track.config[6] = track.sampleRate >>> 8 & 255;
10525
- track.config[7] = track.sampleRate & 255;
10526
- return MP42.box(MP42.types.dOps, track.config);
10527
- }
10528
- }
10529
9766
  }, {
10530
9767
  key: "mvex",
10531
9768
  value: function mvex(tracks) {
@@ -11128,7 +10365,7 @@ var MP4 = /* @__PURE__ */ function() {
11128
10365
  }]);
11129
10366
  return MP42;
11130
10367
  }();
11131
- _defineProperty(MP4, "types", ["Opus", "dOps", "av01", "av1C", "avc1", "avcC", "hvc1", "hvcC", "dinf", "dref", "esds", "ftyp", "hdlr", "mdat", "mdhd", "mdia", "mfhd", "minf", "moof", "moov", "mp4a", "mvex", "mvhd", "pasp", "stbl", "stco", "stsc", "stsd", "stsz", "stts", "tfdt", "tfhd", "traf", "trak", "trex", "tkhd", "vmhd", "smhd", "ctts", "stss", "styp", "pssh", "sidx", "sbgp", "saiz", "saio", "senc", "trun", "encv", "enca", "sinf", "btrt", "frma", "tenc", "schm", "schi", "mehd", "fiel", "sdtp"].reduce(function(p, c) {
10368
+ _defineProperty(MP4, "types", ["avc1", "avcC", "hvc1", "hvcC", "dinf", "dref", "esds", "ftyp", "hdlr", "mdat", "mdhd", "mdia", "mfhd", "minf", "moof", "moov", "mp4a", "mvex", "mvhd", "pasp", "stbl", "stco", "stsc", "stsd", "stsz", "stts", "tfdt", "tfhd", "traf", "trak", "trex", "tkhd", "vmhd", "smhd", "ctts", "stss", "styp", "pssh", "sidx", "sbgp", "saiz", "saio", "senc", "trun", "encv", "enca", "sinf", "btrt", "frma", "tenc", "schm", "schi", "mehd", "fiel", "sdtp"].reduce(function(p, c) {
11132
10369
  p[c] = [c.charCodeAt(0), c.charCodeAt(1), c.charCodeAt(2), c.charCodeAt(3)];
11133
10370
  return p;
11134
10371
  }, /* @__PURE__ */ Object.create(null)));
@@ -11463,46 +10700,30 @@ var FMP4Remuxer = /* @__PURE__ */ function() {
11463
10700
  };
11464
10701
  }
11465
10702
  var samples = track.samples;
11466
- var isAV01 = /av01/.test(track.codec);
11467
10703
  var mdatSize = 0;
11468
- if (isAV01) {
11469
- samples.forEach(function(s) {
11470
- mdatSize += s.data.byteLength;
11471
- });
11472
- } else {
11473
- samples.forEach(function(s) {
11474
- mdatSize += s.units.reduce(function(t, c) {
11475
- return t + c.byteLength;
11476
- }, 0);
11477
- mdatSize += s.units.length * 4;
11478
- });
11479
- }
10704
+ samples.forEach(function(s) {
10705
+ mdatSize += s.units.reduce(function(t, c) {
10706
+ return t + c.byteLength;
10707
+ }, 0);
10708
+ mdatSize += s.units.length * 4;
10709
+ });
11480
10710
  var mdata = new Uint8Array(mdatSize);
11481
- if (isAV01) {
11482
- for (var i = 0, l = samples.length, offset = 0, sample; i < l; i++) {
11483
- sample = samples[i];
11484
- mdata.set(sample.data, offset);
11485
- sample.size = sample.data.byteLength;
11486
- offset += sample.size;
11487
- }
11488
- } else {
11489
- var mdatView = new DataView(mdata.buffer);
11490
- var _loop = function _loop2(_offset2, _sample2) {
11491
- _sample2 = samples[_i];
11492
- var sampleSize = 0;
11493
- _sample2.units.forEach(function(u) {
11494
- mdatView.setUint32(_offset2, u.byteLength);
11495
- _offset2 += 4;
11496
- mdata.set(u, _offset2);
11497
- _offset2 += u.byteLength;
11498
- sampleSize += 4 + u.byteLength;
11499
- });
11500
- _sample2.size = sampleSize;
11501
- _offset = _offset2, _sample = _sample2;
11502
- };
11503
- for (var _i = 0, _l = samples.length, _offset = 0, _sample; _i < _l; _i++) {
11504
- _loop(_offset, _sample);
11505
- }
10711
+ var mdatView = new DataView(mdata.buffer);
10712
+ var _loop = function _loop2(_offset, _sample) {
10713
+ _sample = samples[i];
10714
+ var sampleSize = 0;
10715
+ _sample.units.forEach(function(u) {
10716
+ mdatView.setUint32(_offset, u.byteLength);
10717
+ _offset += 4;
10718
+ mdata.set(u, _offset);
10719
+ _offset += u.byteLength;
10720
+ sampleSize += 4 + u.byteLength;
10721
+ });
10722
+ _sample.size = sampleSize;
10723
+ offset = _offset, sample = _sample;
10724
+ };
10725
+ for (var i = 0, l = samples.length, offset = 0, sample; i < l; i++) {
10726
+ _loop(offset, sample);
11506
10727
  }
11507
10728
  var mdat = MP4.mdat(mdata);
11508
10729
  var moof = MP4.moof([track]);
@@ -11661,11 +10882,11 @@ var Event$1 = _objectSpread2$2(_objectSpread2$2({}, EVENT), {}, {
11661
10882
  });
11662
10883
  var logger$3 = new Logger$2("Transmuxer");
11663
10884
  var Transmuxer = /* @__PURE__ */ function() {
11664
- function Transmuxer2(hls, isMP4, needRemux, fixerConfig) {
10885
+ function Transmuxer2(hls, isMP4, needRemux) {
11665
10886
  _classCallCheck$3(this, Transmuxer2);
11666
10887
  _defineProperty$3(this, "_initSegmentId", "");
11667
10888
  this.hls = hls;
11668
- this._demuxer = isMP4 ? new FMP4Demuxer() : new TsDemuxer(null, null, null, fixerConfig);
10889
+ this._demuxer = isMP4 ? new FMP4Demuxer() : new TsDemuxer();
11669
10890
  this._isMP4 = isMP4;
11670
10891
  if (needRemux)
11671
10892
  this._remuxer = new FMP4Remuxer(this._demuxer.videoTrack, this._demuxer.audioTrack);
@@ -11820,7 +11041,7 @@ var Transmuxer = /* @__PURE__ */ function() {
11820
11041
  }]);
11821
11042
  return Transmuxer2;
11822
11043
  }();
11823
- var _excluded$1 = ["data"], _excluded2 = ["data"];
11044
+ var _excluded = ["data"], _excluded2 = ["data"];
11824
11045
  var logger$2 = new Logger$2("BufferService");
11825
11046
  var BufferService = /* @__PURE__ */ function() {
11826
11047
  function BufferService2(hls) {
@@ -11932,11 +11153,11 @@ var BufferService = /* @__PURE__ */ function() {
11932
11153
  return;
11933
11154
  if (TsDemuxer.probe(chunk)) {
11934
11155
  if (!this._transmuxer)
11935
- this._transmuxer = new Transmuxer(this.hls, false, !this._softVideo, this.hls.config.fixerConfig);
11156
+ this._transmuxer = new Transmuxer(this.hls, false, !this._softVideo);
11936
11157
  } else if (MP4Parser.probe(chunk)) {
11937
11158
  if (this._softVideo) {
11938
11159
  if (!this._transmuxer)
11939
- this._transmuxer = new Transmuxer(this.hls, true, null, this.hls.config.fixerConfig);
11160
+ this._transmuxer = new Transmuxer(this.hls, true);
11940
11161
  } else {
11941
11162
  this._directAppend = true;
11942
11163
  var mix = false;
@@ -11986,8 +11207,7 @@ var BufferService = /* @__PURE__ */ function() {
11986
11207
  key: "appendBuffer",
11987
11208
  value: function() {
11988
11209
  var _appendBuffer = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2(segment, audioSegment, videoChunk, audioChunk, discontinuity, contiguous, startTime) {
11989
- var _this2 = this;
11990
- var afterAppend, p, needInit, _this$_transmuxer$tra, _this$_transmuxer$tra2, video, audio, isFirstAppend, mse, _p, videoData, videoRest, audioData, audioRest;
11210
+ var p, needInit, _this$_transmuxer$tra, _this$_transmuxer$tra2, video, audio, isFirstAppend, mse, _p, videoData, videoRest, audioData, audioRest;
11991
11211
  return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
11992
11212
  while (1)
11993
11213
  switch (_context2.prev = _context2.next) {
@@ -11998,18 +11218,8 @@ var BufferService = /* @__PURE__ */ function() {
11998
11218
  }
11999
11219
  return _context2.abrupt("return");
12000
11220
  case 2:
12001
- afterAppend = function afterAppend2() {
12002
- var _this2$hls;
12003
- if ((_this2$hls = _this2.hls) !== null && _this2$hls !== void 0 && _this2$hls.emit) {
12004
- var _this2$hls2;
12005
- (_this2$hls2 = _this2.hls) === null || _this2$hls2 === void 0 ? void 0 : _this2$hls2.emit(EVENT.APPEND_BUFFER, {
12006
- start: segment.start,
12007
- end: segment.end
12008
- });
12009
- }
12010
- };
12011
11221
  if (!this._directAppend) {
12012
- _context2.next = 8;
11222
+ _context2.next = 7;
12013
11223
  break;
12014
11224
  }
12015
11225
  p = [];
@@ -12017,8 +11227,8 @@ var BufferService = /* @__PURE__ */ function() {
12017
11227
  p.push(this._mse.append(MSE.VIDEO, videoChunk));
12018
11228
  if (audioChunk)
12019
11229
  p.push(this._mse.append(MSE.AUDIO, audioChunk));
12020
- return _context2.abrupt("return", Promise.all(p).then(afterAppend));
12021
- case 8:
11230
+ return _context2.abrupt("return", Promise.all(p));
11231
+ case 7:
12022
11232
  needInit = this._needInitSegment || discontinuity;
12023
11233
  _this$_transmuxer$tra = this._transmuxer.transmux(videoChunk, audioChunk, needInit, contiguous, startTime, this._needInitSegment || discontinuity), _this$_transmuxer$tra2 = _slicedToArray$1(_this$_transmuxer$tra, 2), video = _this$_transmuxer$tra2[0], audio = _this$_transmuxer$tra2[1];
12024
11234
  if (audioChunk && audioSegment) {
@@ -12034,17 +11244,16 @@ var BufferService = /* @__PURE__ */ function() {
12034
11244
  this.hls.emit(Event$1.NO_AUDIO_TRACK);
12035
11245
  }
12036
11246
  if (!this._softVideo) {
12037
- _context2.next = 20;
11247
+ _context2.next = 18;
12038
11248
  break;
12039
11249
  }
12040
11250
  this._softVideo.appendBuffer(video, audio);
12041
11251
  this._needInitSegment = false;
12042
- afterAppend();
12043
- _context2.next = 30;
11252
+ _context2.next = 28;
12044
11253
  break;
12045
- case 20:
11254
+ case 18:
12046
11255
  if (!this._mse) {
12047
- _context2.next = 30;
11256
+ _context2.next = 28;
12048
11257
  break;
12049
11258
  }
12050
11259
  isFirstAppend = !this._sourceCreated;
@@ -12060,15 +11269,15 @@ var BufferService = /* @__PURE__ */ function() {
12060
11269
  });
12061
11270
  }
12062
11271
  if (video) {
12063
- videoData = video.data, videoRest = _objectWithoutProperties$1(video, _excluded$1);
11272
+ videoData = video.data, videoRest = _objectWithoutProperties$1(video, _excluded);
12064
11273
  _p.push(mse.append(MSE.VIDEO, videoData, videoRest));
12065
11274
  }
12066
11275
  if (audio) {
12067
11276
  audioData = audio.data, audioRest = _objectWithoutProperties$1(audio, _excluded2);
12068
11277
  _p.push(mse.append(MSE.AUDIO, audioData, audioRest));
12069
11278
  }
12070
- return _context2.abrupt("return", Promise.all(_p).then(afterAppend));
12071
- case 30:
11279
+ return _context2.abrupt("return", Promise.all(_p));
11280
+ case 28:
12072
11281
  case "end":
12073
11282
  return _context2.stop();
12074
11283
  }
@@ -12083,7 +11292,7 @@ var BufferService = /* @__PURE__ */ function() {
12083
11292
  key: "removeBuffer",
12084
11293
  value: function() {
12085
11294
  var _removeBuffer = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee3() {
12086
- var _this3 = this;
11295
+ var _this2 = this;
12087
11296
  var start, end, media, _args3 = arguments;
12088
11297
  return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
12089
11298
  while (1)
@@ -12099,7 +11308,7 @@ var BufferService = /* @__PURE__ */ function() {
12099
11308
  return _context3.abrupt("return");
12100
11309
  case 5:
12101
11310
  return _context3.abrupt("return", this._mse.clearBuffer(start, end).then(function() {
12102
- return _this3.hls.emit(EVENT.REMOVE_BUFFER, {
11311
+ return _this2.hls.emit(EVENT.REMOVE_BUFFER, {
12103
11312
  start,
12104
11313
  end,
12105
11314
  removeEnd: end
@@ -12280,51 +11489,30 @@ var BufferService = /* @__PURE__ */ function() {
12280
11489
  return setLiveSeekableRange;
12281
11490
  }()
12282
11491
  }, {
12283
- key: "detachMedia",
11492
+ key: "destroy",
12284
11493
  value: function() {
12285
- var _detachMedia = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee9() {
11494
+ var _destroy = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee9() {
11495
+ var _this$_decryptor;
12286
11496
  return _regeneratorRuntime$1().wrap(function _callee9$(_context9) {
12287
11497
  while (1)
12288
11498
  switch (_context9.prev = _context9.next) {
12289
11499
  case 0:
11500
+ (_this$_decryptor = this._decryptor) === null || _this$_decryptor === void 0 ? void 0 : _this$_decryptor.destroy();
12290
11501
  if (!this._mse) {
12291
- _context9.next = 3;
11502
+ _context9.next = 4;
12292
11503
  break;
12293
11504
  }
12294
- _context9.next = 3;
11505
+ _context9.next = 4;
12295
11506
  return this._mse.unbindMedia();
12296
- case 3:
12297
- case "end":
12298
- return _context9.stop();
12299
- }
12300
- }, _callee9, this);
12301
- }));
12302
- function detachMedia() {
12303
- return _detachMedia.apply(this, arguments);
12304
- }
12305
- return detachMedia;
12306
- }()
12307
- }, {
12308
- key: "destroy",
12309
- value: function() {
12310
- var _destroy = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee10() {
12311
- var _this$_decryptor;
12312
- return _regeneratorRuntime$1().wrap(function _callee10$(_context10) {
12313
- while (1)
12314
- switch (_context10.prev = _context10.next) {
12315
- case 0:
12316
- (_this$_decryptor = this._decryptor) === null || _this$_decryptor === void 0 ? void 0 : _this$_decryptor.destroy();
12317
- _context10.next = 3;
12318
- return this.detachMedia();
12319
- case 3:
11507
+ case 4:
12320
11508
  this._decryptor = null;
12321
11509
  this._mse = null;
12322
11510
  this._softVideo = null;
12323
- case 6:
11511
+ case 7:
12324
11512
  case "end":
12325
- return _context10.stop();
11513
+ return _context9.stop();
12326
11514
  }
12327
- }, _callee10, this);
11515
+ }, _callee9, this);
12328
11516
  }));
12329
11517
  function destroy() {
12330
11518
  return _destroy.apply(this, arguments);
@@ -12412,11 +11600,7 @@ function getConfig(cfg) {
12412
11600
  minSegmentsStartPlay: 3,
12413
11601
  preferMMS: false,
12414
11602
  preferMMSStreaming: false,
12415
- mseLowLatency: true,
12416
- fixerConfig: {
12417
- forceFixLargeGap: false,
12418
- largeGapThreshold: 5
12419
- }
11603
+ mseLowLatency: true
12420
11604
  }, cfg), {}, {
12421
11605
  media
12422
11606
  });
@@ -12531,8 +11715,6 @@ var MediaPlaylist = /* @__PURE__ */ _createClass$3(function MediaPlaylist2() {
12531
11715
  _defineProperty$3(this, "lowLatency", false);
12532
11716
  _defineProperty$3(this, "endPartIndex", 0);
12533
11717
  _defineProperty$3(this, "segments", []);
12534
- _defineProperty$3(this, "dateRanges", {});
12535
- _defineProperty$3(this, "skippedSegments", 0);
12536
11718
  });
12537
11719
  var MediaSegment = /* @__PURE__ */ function() {
12538
11720
  function MediaSegment2(parentUrl) {
@@ -12654,31 +11836,6 @@ var MediaSegmentKey = /* @__PURE__ */ function() {
12654
11836
  }]);
12655
11837
  return MediaSegmentKey2;
12656
11838
  }();
12657
- var HlsUrlParameters = /* @__PURE__ */ function() {
12658
- function HlsUrlParameters2(msn, part, skip) {
12659
- _classCallCheck$3(this, HlsUrlParameters2);
12660
- this.msn = msn;
12661
- this.part = part;
12662
- this.skip = skip;
12663
- }
12664
- _createClass$3(HlsUrlParameters2, [{
12665
- key: "addDirectives",
12666
- value: function addDirectives(uri) {
12667
- var url = new self.URL(uri);
12668
- if (this.msn !== void 0) {
12669
- url.searchParams.set("_HLS_msn", this.msn.toString());
12670
- }
12671
- if (this.part) {
12672
- url.searchParams.set("_HLS_part", this.part.toString());
12673
- }
12674
- if (this.skip) {
12675
- url.searchParams.set("_HLS_skip", this.skip);
12676
- }
12677
- return url.href;
12678
- }
12679
- }]);
12680
- return HlsUrlParameters2;
12681
- }();
12682
11839
  var REGEXP_TAG = /^#(EXT[^:]*)(?::(.*))?$/;
12683
11840
  var REGEXP_ATTR = /([^=]+)=(?:"([^"]*)"|([^",]*))(?:,|$)/g;
12684
11841
  var REGEXP_ABSOLUTE_URL = /^(?:[a-zA-Z0-9+\-.]+:)?\/\//;
@@ -12729,38 +11886,6 @@ function getCodecs(type, codecs) {
12729
11886
  }
12730
11887
  }
12731
11888
  }
12732
- function isValidDaterange(attr, dateRangeWithSameId) {
12733
- var _badValueForSameId;
12734
- if (dateRangeWithSameId) {
12735
- for (var key in dateRangeWithSameId) {
12736
- if (Object.prototype.hasOwnProperty.call(dateRangeWithSameId, key) && attr[key] !== dateRangeWithSameId[key]) {
12737
- _badValueForSameId = key;
12738
- break;
12739
- }
12740
- }
12741
- }
12742
- var duration = null;
12743
- if (attr.DURATION) {
12744
- duration = parseFloat(attr.DURATION);
12745
- if (!Number.isFinite(duration)) {
12746
- duration = null;
12747
- } else if (attr._endDate) {
12748
- duration = (attr._endDate.getTime() - attr._startDate.getTime()) / 1e3;
12749
- }
12750
- }
12751
- var cue = enumeratedStringList(attr.CUE || attr["X-CUE"], {
12752
- pre: false,
12753
- post: false,
12754
- once: false
12755
- });
12756
- return !!attr.ID && !_badValueForSameId && Number.isFinite(attr._startDate.getTime()) && (duration === null || duration >= 0) && (!(attr.END_ON_NEXT === "YES") || !!attr.CLASS) && (!attr.CUE || !cue.pre && !cue.post || cue.pre !== cue.post) && (!(attr.CLASS === "com.apple.hls.interstitial") || "X-ASSET-URI" in attr || "X-ASSET-LIST" in attr);
12757
- }
12758
- function enumeratedStringList(attrValue, dict) {
12759
- return (attrValue ? attrValue.split(/[ ,]+/) : []).reduce(function(result, identifier) {
12760
- result[identifier.toLowerCase()] = true;
12761
- return result;
12762
- }, dict);
12763
- }
12764
11889
  function parseMasterPlaylist(lines, parentUrl) {
12765
11890
  var master = new MasterPlaylist();
12766
11891
  var index = 0;
@@ -12869,6 +11994,9 @@ function parseMediaPlaylist(lines, parentUrl, useLowLatency) {
12869
11994
  var endOfList = false;
12870
11995
  var partSegmentIndex = 0;
12871
11996
  while (line = lines[index++]) {
11997
+ if (endOfList) {
11998
+ break;
11999
+ }
12872
12000
  if (line[0] !== "#") {
12873
12001
  if (media.lowLatency) {
12874
12002
  curSN++;
@@ -12917,11 +12045,16 @@ function parseMediaPlaylist(lines, parentUrl, useLowLatency) {
12917
12045
  media.canBlockReload = _attr["CAN-BLOCK-RELOAD"] === "YES";
12918
12046
  media.partHoldBack = parseFloat(_attr["PART-HOLD-BACK"] || 0);
12919
12047
  media.canSkipUntil = parseFloat(_attr["CAN-SKIP-UNTIL"] || 0);
12920
- media.canSkipDateRanges = media.canSkipUntil > 0 && _attr["CAN-SKIP-DATERANGES"] === "YES";
12048
+ media.canSkipDateRanges = _attr["CAN-SKIP-DATERANGES"] === "YES";
12921
12049
  }
12922
12050
  break;
12923
12051
  case "ENDLIST":
12924
12052
  {
12053
+ var _lastSegment = media.segments[media.segments.length - 1];
12054
+ if (_lastSegment) {
12055
+ _lastSegment.isLast = true;
12056
+ }
12057
+ media.live = false;
12925
12058
  endOfList = true;
12926
12059
  }
12927
12060
  break;
@@ -12961,15 +12094,6 @@ function parseMediaPlaylist(lines, parentUrl, useLowLatency) {
12961
12094
  }
12962
12095
  break;
12963
12096
  case "PRELOAD-HINT":
12964
- {
12965
- var _attr3 = parseAttr(data);
12966
- media.preloadHint = _attr3;
12967
- if (_attr3["TYPE"] === "PART" && _attr3["URI"]) {
12968
- var tmp = _attr3["URI"].split(".ts")[0].split("-");
12969
- media.nextSN = tmp[3];
12970
- media.nextIndex = tmp[tmp.length - 1];
12971
- }
12972
- }
12973
12097
  break;
12974
12098
  case "PROGRAM-DATE-TIME":
12975
12099
  curSegment.dataTime = data;
@@ -12989,21 +12113,21 @@ function parseMediaPlaylist(lines, parentUrl, useLowLatency) {
12989
12113
  break;
12990
12114
  case "KEY":
12991
12115
  {
12992
- var _attr4 = parseAttr(data);
12993
- if (_attr4.METHOD === "NONE") {
12116
+ var _attr3 = parseAttr(data);
12117
+ if (_attr3.METHOD === "NONE") {
12994
12118
  curKey = null;
12995
12119
  break;
12996
12120
  }
12997
12121
  curKey = new MediaSegmentKey();
12998
- curKey.method = _attr4.METHOD;
12999
- curKey.url = /^blob:/.test(_attr4.URI) ? _attr4.URI : getAbsoluteUrl(_attr4.URI, parentUrl);
13000
- curKey.keyFormat = _attr4.KEYFORMAT || "identity";
13001
- curKey.keyFormatVersions = _attr4.KEYFORMATVERSIONS;
12122
+ curKey.method = _attr3.METHOD;
12123
+ curKey.url = /^blob:/.test(_attr3.URI) ? _attr3.URI : getAbsoluteUrl(_attr3.URI, parentUrl);
12124
+ curKey.keyFormat = _attr3.KEYFORMAT || "identity";
12125
+ curKey.keyFormatVersions = _attr3.KEYFORMATVERSIONS;
13002
12126
  if (!curKey.isSupported()) {
13003
- throw new Error("encrypt ".concat(_attr4.METHOD, "/").concat(_attr4.KEYFORMAT, " is not supported"));
12127
+ throw new Error("encrypt ".concat(_attr3.METHOD, "/").concat(_attr3.KEYFORMAT, " is not supported"));
13004
12128
  }
13005
- if (_attr4.IV) {
13006
- var str = _attr4.IV.slice(2);
12129
+ if (_attr3.IV) {
12130
+ var str = _attr3.IV.slice(2);
13007
12131
  str = (str.length & 1 ? "0" : "") + str;
13008
12132
  curKey.iv = new Uint8Array(str.length / 2);
13009
12133
  for (var i = 0, l = str.length / 2; i < l; i++) {
@@ -13014,10 +12138,10 @@ function parseMediaPlaylist(lines, parentUrl, useLowLatency) {
13014
12138
  break;
13015
12139
  case "MAP":
13016
12140
  {
13017
- var _attr5 = parseAttr(data);
13018
- curSegment.url = getAbsoluteUrl(_attr5.URI, parentUrl);
13019
- if (_attr5.BYTERANGE)
13020
- curSegment.setByteRange(_attr5.BYTERANGE);
12141
+ var _attr4 = parseAttr(data);
12142
+ curSegment.url = getAbsoluteUrl(_attr4.URI, parentUrl);
12143
+ if (_attr4.BYTERANGE)
12144
+ curSegment.setByteRange(_attr4.BYTERANGE);
13021
12145
  curSegment.isInitSegment = true;
13022
12146
  curSegment.sn = 0;
13023
12147
  if (curKey) {
@@ -13027,30 +12151,6 @@ function parseMediaPlaylist(lines, parentUrl, useLowLatency) {
13027
12151
  curSegment = new MediaSegment(parentUrl);
13028
12152
  }
13029
12153
  break;
13030
- case "SKIP":
13031
- {
13032
- var _attr6 = parseAttr(data);
13033
- var skippedSegments = parseInt(_attr6["SKIPPED-SEGMENTS"], 10);
13034
- if (skippedSegments <= Number.MAX_SAFE_INTEGER) {
13035
- media.skippedSegments += skippedSegments;
13036
- curSN += skippedSegments;
13037
- }
13038
- }
13039
- break;
13040
- case "DATERANGE":
13041
- {
13042
- var _attr7 = parseAttr(data);
13043
- var dateRangeWithSameId = media.dateRanges[_attr7.ID];
13044
- _attr7._startDate = dateRangeWithSameId ? dateRangeWithSameId._startDate : new Date(_attr7["START-DATE"]);
13045
- var endDate = (dateRangeWithSameId === null || dateRangeWithSameId === void 0 ? void 0 : dateRangeWithSameId._endDate) || new Date(_attr7.END_DATE);
13046
- if (Number.isFinite(endDate)) {
13047
- _attr7._endDate = endDate;
13048
- }
13049
- if (isValidDaterange(_attr7, dateRangeWithSameId) || media.skippedSegments) {
13050
- media.dateRanges[_attr7.ID] = _attr7;
13051
- }
13052
- }
13053
- break;
13054
12154
  }
13055
12155
  }
13056
12156
  media.segments = media.segments.filter(function(x) {
@@ -13058,14 +12158,11 @@ function parseMediaPlaylist(lines, parentUrl, useLowLatency) {
13058
12158
  });
13059
12159
  var lastSegment = media.segments[media.segments.length - 1];
13060
12160
  if (lastSegment) {
13061
- if (endOfList) {
13062
- lastSegment.isLast = true;
13063
- }
13064
12161
  media.endSN = lastSegment.sn;
13065
12162
  media.endPartIndex = lastSegment.partIndex;
13066
- }
13067
- if (endOfList) {
13068
- media.live = false;
12163
+ if (endOfList && !lastSegment.isLast) {
12164
+ lastSegment.isLast = true;
12165
+ }
13069
12166
  }
13070
12167
  media.totalDuration = totalDuration;
13071
12168
  media.endCC = curCC;
@@ -13244,13 +12341,6 @@ var ManifestLoader = /* @__PURE__ */ function() {
13244
12341
  playlist
13245
12342
  });
13246
12343
  } else {
13247
- if (this._useLowLatency) {
13248
- if (playlist.canBlockReload) {
13249
- this.deliveryDirectives = new HlsUrlParameters(playlist.nextSN, playlist.nextIndex, "");
13250
- } else {
13251
- this.deliveryDirectives = null;
13252
- }
13253
- }
13254
12344
  this.hls.emit(Event$1.HLS_LEVEL_LOADED, {
13255
12345
  playlist
13256
12346
  });
@@ -13307,45 +12397,41 @@ var ManifestLoader = /* @__PURE__ */ function() {
13307
12397
  var retryCount = this.hls.config.pollRetryCount;
13308
12398
  var fn = /* @__PURE__ */ function() {
13309
12399
  var _ref2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2() {
13310
- var reqUrl, res;
12400
+ var res;
13311
12401
  return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
13312
12402
  while (1)
13313
12403
  switch (_context2.prev = _context2.next) {
13314
12404
  case 0:
13315
12405
  clearTimeout(_this2._timer);
13316
- reqUrl = url;
13317
- _context2.prev = 2;
13318
- if (_this2.deliveryDirectives) {
13319
- reqUrl = _this2.deliveryDirectives.addDirectives(url);
13320
- }
13321
- _context2.next = 6;
13322
- return _this2.load(reqUrl, audioUrl, subtitleUrl);
13323
- case 6:
12406
+ _context2.prev = 1;
12407
+ _context2.next = 4;
12408
+ return _this2.load(url, audioUrl, subtitleUrl);
12409
+ case 4:
13324
12410
  res = _context2.sent;
13325
12411
  if (res[0]) {
13326
- _context2.next = 9;
12412
+ _context2.next = 7;
13327
12413
  break;
13328
12414
  }
13329
12415
  return _context2.abrupt("return");
13330
- case 9:
12416
+ case 7:
13331
12417
  retryCount = _this2.hls.config.pollRetryCount;
13332
12418
  cb(res[0], res[1], res[2]);
13333
- _context2.next = 17;
12419
+ _context2.next = 15;
13334
12420
  break;
13335
- case 13:
13336
- _context2.prev = 13;
13337
- _context2.t0 = _context2["catch"](2);
12421
+ case 11:
12422
+ _context2.prev = 11;
12423
+ _context2.t0 = _context2["catch"](1);
13338
12424
  retryCount--;
13339
12425
  if (retryCount <= 0) {
13340
12426
  errorCb(_context2.t0);
13341
12427
  }
13342
- case 17:
12428
+ case 15:
13343
12429
  _this2._timer = setTimeout(fn, time);
13344
- case 18:
12430
+ case 16:
13345
12431
  case "end":
13346
12432
  return _context2.stop();
13347
12433
  }
13348
- }, _callee2, null, [[2, 13]]);
12434
+ }, _callee2, null, [[1, 11]]);
13349
12435
  }));
13350
12436
  return function fn2() {
13351
12437
  return _ref2.apply(this, arguments);
@@ -13875,7 +12961,7 @@ var Playlist = /* @__PURE__ */ function() {
13875
12961
  }, {
13876
12962
  key: "clearOldSegment",
13877
12963
  value: function clearOldSegment() {
13878
- var maxPlaylistSize = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.hls.config.maxPlaylistSize || 50;
12964
+ var maxPlaylistSize = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 50;
13879
12965
  var stream = this.currentStream;
13880
12966
  if (!this.dvrWindow || !stream)
13881
12967
  return;
@@ -14173,7 +13259,7 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
14173
13259
  _defineProperty$3(_assertThisInitialized$2(_this), "_switchUrlOpts", null);
14174
13260
  _defineProperty$3(_assertThisInitialized$2(_this), "_isProcessQuotaExceeded", false);
14175
13261
  _defineProperty$3(_assertThisInitialized$2(_this), "_loadSegment", /* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee() {
14176
- var _this$_playlist, nextSegment, lastSegment, _assertThisInitialize, config, minFrameDuration, maxBufferThroughout, bInfo, bufferThroughout;
13262
+ var nextSeg, _assertThisInitialize, config, bInfo, bufferThroughout;
14177
13263
  return _regeneratorRuntime$1().wrap(function _callee$(_context) {
14178
13264
  while (1)
14179
13265
  switch (_context.prev = _context.next) {
@@ -14184,44 +13270,42 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
14184
13270
  }
14185
13271
  return _context.abrupt("return");
14186
13272
  case 2:
14187
- _this$_playlist = _this._playlist, nextSegment = _this$_playlist.nextSegment, lastSegment = _this$_playlist.lastSegment;
13273
+ nextSeg = _this._playlist.nextSegment;
14188
13274
  _assertThisInitialize = _assertThisInitialized$2(_this), config = _assertThisInitialize.config;
14189
- minFrameDuration = 0.016;
14190
- maxBufferThroughout = Math.min(Math.max((lastSegment === null || lastSegment === void 0 ? void 0 : lastSegment.duration) - minFrameDuration / 2 || 0, minFrameDuration), 0.1);
14191
- if (nextSegment) {
14192
- _context.next = 8;
13275
+ if (nextSeg) {
13276
+ _context.next = 6;
14193
13277
  break;
14194
13278
  }
14195
13279
  return _context.abrupt("return");
14196
- case 8:
13280
+ case 6:
14197
13281
  if (_this.isLive) {
14198
- _context.next = 18;
13282
+ _context.next = 16;
14199
13283
  break;
14200
13284
  }
14201
13285
  bInfo = _this.bufferInfo();
14202
13286
  if (_this.media.paused && !_this.media.currentTime) {
14203
13287
  bInfo = _this.bufferInfo(bInfo.nextStart || 0.5);
14204
13288
  }
14205
- bufferThroughout = Math.abs(bInfo.end - _this.media.duration) < maxBufferThroughout;
13289
+ bufferThroughout = Math.abs(bInfo.end - _this.media.duration) < 0.1;
14206
13290
  if (!(bInfo.remaining >= config.preloadTime || bufferThroughout)) {
14207
- _context.next = 15;
13291
+ _context.next = 13;
14208
13292
  break;
14209
13293
  }
14210
13294
  _this._tryEos();
14211
13295
  return _context.abrupt("return");
14212
- case 15:
13296
+ case 13:
14213
13297
  if (!(config.preferMMSStreaming && !_this._bufferService.msStreaming)) {
14214
- _context.next = 17;
13298
+ _context.next = 15;
14215
13299
  break;
14216
13300
  }
14217
13301
  return _context.abrupt("return");
14218
- case 17:
14219
- if (!_this._urlSwitching && _this._prevSegSn !== nextSegment.sn - 1 && bInfo.end && Math.abs(nextSegment.start - bInfo.end) > 1) {
13302
+ case 15:
13303
+ if (!_this._urlSwitching && _this._prevSegSn !== nextSeg.sn - 1 && bInfo.end && Math.abs(nextSeg.start - bInfo.end) > 1) {
14220
13304
  _this._playlist.setNextSegmentByIndex(_this._playlist.findSegmentIndexByTime(bInfo.end + 0.1));
14221
13305
  }
14222
- case 18:
13306
+ case 16:
14223
13307
  return _context.abrupt("return", _this._loadSegmentDirect());
14224
- case 19:
13308
+ case 17:
14225
13309
  case "end":
14226
13310
  return _context.stop();
14227
13311
  }
@@ -14386,6 +13470,7 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
14386
13470
  return;
14387
13471
  _this._startTick();
14388
13472
  var media = _this.media;
13473
+ var buffered = Buffer$1.get(media);
14389
13474
  var segLoaderError = _this._segmentLoader.error;
14390
13475
  _this._onCheckQuotaExceeded();
14391
13476
  if (_this._isProcessQuotaExceeded) {
@@ -14402,7 +13487,7 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
14402
13487
  }
14403
13488
  return;
14404
13489
  }
14405
- if (media.readyState) {
13490
+ if (Buffer$1.end(buffered) >= 0.1 && media.readyState) {
14406
13491
  if (isMediaPlaying(media)) {
14407
13492
  _this._loadSegment();
14408
13493
  if (_this._gapService) {
@@ -14468,12 +13553,6 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
14468
13553
  var _this$_bufferService;
14469
13554
  return (_this$_bufferService = this._bufferService) === null || _this$_bufferService === void 0 ? void 0 : _this$_bufferService.baseDts;
14470
13555
  }
14471
- }, {
14472
- key: "abrSwitchPoint",
14473
- get: function get() {
14474
- var targetSeg = this._urlSwitching ? this._playlist.currentSegment : this._playlist.nextSegment;
14475
- return targetSeg ? targetSeg.start + targetSeg.duration / 2 : null;
14476
- }
14477
13556
  }, {
14478
13557
  key: "speedInfo",
14479
13558
  value: function speedInfo() {
@@ -14499,37 +13578,30 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
14499
13578
  }, {
14500
13579
  key: "load",
14501
13580
  value: function() {
14502
- var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee4() {
14503
- var url, options, reuseMse, _args4 = arguments;
13581
+ var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee4(url) {
13582
+ var reuseMse, _args4 = arguments;
14504
13583
  return _regeneratorRuntime$1().wrap(function _callee4$(_context4) {
14505
13584
  while (1)
14506
13585
  switch (_context4.prev = _context4.next) {
14507
13586
  case 0:
14508
- url = _args4.length > 0 && _args4[0] !== void 0 ? _args4[0] : "";
14509
- options = _args4.length > 1 && _args4[1] !== void 0 ? _args4[1] : {};
14510
- reuseMse = typeof options === "boolean" ? options : !!(options !== null && options !== void 0 && options.reuseMse);
14511
- if (_typeof$2(options) === "object" && options !== null && options !== void 0 && options.clearSwitchStatus) {
14512
- this._urlSwitching = false;
14513
- this._switchUrlOpts = null;
14514
- this.config.startTime = void 0;
14515
- }
13587
+ reuseMse = _args4.length > 1 && _args4[1] !== void 0 ? _args4[1] : false;
14516
13588
  if (url)
14517
13589
  this.config.url = url;
14518
13590
  url = this.config.url;
14519
- _context4.next = 8;
13591
+ _context4.next = 5;
14520
13592
  return this._reset(reuseMse);
14521
- case 8:
14522
- _context4.next = 10;
13593
+ case 5:
13594
+ _context4.next = 7;
14523
13595
  return this._loadData(url);
14524
- case 10:
13596
+ case 7:
14525
13597
  this._startTick();
14526
- case 11:
13598
+ case 8:
14527
13599
  case "end":
14528
13600
  return _context4.stop();
14529
13601
  }
14530
13602
  }, _callee4, this);
14531
13603
  }));
14532
- function load() {
13604
+ function load(_x) {
14533
13605
  return _load.apply(this, arguments);
14534
13606
  }
14535
13607
  return load;
@@ -14538,7 +13610,7 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
14538
13610
  key: "_loadData",
14539
13611
  value: function() {
14540
13612
  var _loadData2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee5(url) {
14541
- var manifest, currentStream, preIndex, _this$_switchUrlOpts, _this$_switchUrlOpts3, _this$_switchUrlOpts4, _this$_switchUrlOpts2, switchTimePoint, segIdx, nextSeg, bufferClearStartPoint, startTime, _this$_switchUrlOpts5;
13613
+ var manifest, currentStream, _this$_switchUrlOpts, _this$_switchUrlOpts2, switchTimePoint, segIdx, nextSeg, bufferClearStartPoint, preIndex, startTime, _this$_switchUrlOpts3;
14542
13614
  return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
14543
13615
  while (1)
14544
13616
  switch (_context5.prev = _context5.next) {
@@ -14559,46 +13631,41 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
14559
13631
  case 5:
14560
13632
  manifest = _context5.sent;
14561
13633
  currentStream = this._playlist.currentStream;
14562
- if (!this._urlSwitching) {
14563
- _context5.next = 23;
14564
- break;
14565
- }
14566
- if (!this.isLive) {
14567
- _context5.next = 14;
13634
+ if (!(this._urlSwitching && !this.isLive)) {
13635
+ _context5.next = 17;
14568
13636
  break;
14569
13637
  }
14570
- preIndex = this._playlist.setNextSegmentBySN(this._prevSegSn);
14571
- logger.log("segment nb=".concat(this._prevSegSn, " index of ").concat(preIndex, " in the new playlist"));
14572
- if (preIndex === -1) {
14573
- this._prevSegCc = null;
14574
- this._prevSegSn = null;
14575
- }
14576
- _context5.next = 23;
14577
- break;
14578
- case 14:
14579
13638
  if (currentStream.bitrate === 0 && (_this$_switchUrlOpts = this._switchUrlOpts) !== null && _this$_switchUrlOpts !== void 0 && _this$_switchUrlOpts.bitrate) {
14580
13639
  currentStream.bitrate = (_this$_switchUrlOpts2 = this._switchUrlOpts) === null || _this$_switchUrlOpts2 === void 0 ? void 0 : _this$_switchUrlOpts2.bitrate;
14581
13640
  }
14582
- switchTimePoint = typeof ((_this$_switchUrlOpts3 = this._switchUrlOpts) === null || _this$_switchUrlOpts3 === void 0 ? void 0 : _this$_switchUrlOpts3.startTime) === "number" ? (_this$_switchUrlOpts4 = this._switchUrlOpts) === null || _this$_switchUrlOpts4 === void 0 ? void 0 : _this$_switchUrlOpts4.startTime : this._getSeamlessSwitchPoint();
13641
+ switchTimePoint = this._getSeamlessSwitchPoint();
14583
13642
  this.config.startTime = switchTimePoint;
14584
13643
  segIdx = this._playlist.findSegmentIndexByTime(switchTimePoint);
14585
13644
  nextSeg = this._playlist.getSegmentByIndex(segIdx + 1);
14586
13645
  if (!nextSeg) {
14587
- _context5.next = 23;
13646
+ _context5.next = 17;
14588
13647
  break;
14589
13648
  }
14590
13649
  bufferClearStartPoint = nextSeg.start;
14591
- _context5.next = 23;
13650
+ _context5.next = 17;
14592
13651
  return this._bufferService.removeBuffer(bufferClearStartPoint);
14593
- case 23:
13652
+ case 17:
13653
+ if (this._urlSwitching && this.isLive) {
13654
+ preIndex = this._playlist.setNextSegmentBySN(this._prevSegSn);
13655
+ logger.log("segment nb=".concat(this._prevSegSn, " index of ").concat(preIndex, " in the new playlist"));
13656
+ if (preIndex === -1) {
13657
+ this._prevSegCc = null;
13658
+ this._prevSegSn = null;
13659
+ }
13660
+ }
14594
13661
  if (manifest) {
14595
- _context5.next = 25;
13662
+ _context5.next = 20;
14596
13663
  break;
14597
13664
  }
14598
13665
  return _context5.abrupt("return");
14599
- case 25:
13666
+ case 20:
14600
13667
  if (!this.isLive) {
14601
- _context5.next = 36;
13668
+ _context5.next = 31;
14602
13669
  break;
14603
13670
  }
14604
13671
  this._bufferService.setLiveSeekableRange(0, 4294967295);
@@ -14611,35 +13678,35 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
14611
13678
  if (!manifest.isMaster)
14612
13679
  this._pollM3U8(url);
14613
13680
  if (!(this._playlist.nbSegments < this.config.minSegmentsStartPlay)) {
14614
- _context5.next = 33;
13681
+ _context5.next = 28;
14615
13682
  break;
14616
13683
  }
14617
13684
  return _context5.abrupt("return");
14618
- case 33:
14619
- _context5.next = 35;
13685
+ case 28:
13686
+ _context5.next = 30;
14620
13687
  return this._loadSegment();
14621
- case 35:
13688
+ case 30:
14622
13689
  return _context5.abrupt("return");
14623
- case 36:
14624
- _context5.next = 38;
13690
+ case 31:
13691
+ _context5.next = 33;
14625
13692
  return this._bufferService.updateDuration(currentStream.totalDuration);
14626
- case 38:
13693
+ case 33:
14627
13694
  startTime = this.config.startTime;
14628
13695
  if (startTime) {
14629
- if (!((_this$_switchUrlOpts5 = this._switchUrlOpts) !== null && _this$_switchUrlOpts5 !== void 0 && _this$_switchUrlOpts5.seamless)) {
13696
+ if (!((_this$_switchUrlOpts3 = this._switchUrlOpts) !== null && _this$_switchUrlOpts3 !== void 0 && _this$_switchUrlOpts3.seamless)) {
14630
13697
  this.media.currentTime = startTime;
14631
13698
  }
14632
13699
  this._playlist.setNextSegmentByIndex(this._playlist.findSegmentIndexByTime(startTime) || 0);
14633
13700
  }
14634
- _context5.next = 42;
13701
+ _context5.next = 37;
14635
13702
  return this._loadSegment();
14636
- case 42:
13703
+ case 37:
14637
13704
  case "end":
14638
13705
  return _context5.stop();
14639
13706
  }
14640
13707
  }, _callee5, this);
14641
13708
  }));
14642
- function _loadData(_x) {
13709
+ function _loadData(_x2) {
14643
13710
  return _loadData2.apply(this, arguments);
14644
13711
  }
14645
13712
  return _loadData;
@@ -14653,20 +13720,18 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
14653
13720
  switch (_context6.prev = _context6.next) {
14654
13721
  case 0:
14655
13722
  this.config.startTime = 0;
14656
- this._urlSwitching = false;
14657
- this._switchUrlOpts = null;
14658
- _context6.next = 5;
13723
+ _context6.next = 3;
14659
13724
  return this.load();
14660
- case 5:
13725
+ case 3:
14661
13726
  this._reloadOnPlay = false;
14662
13727
  return _context6.abrupt("return", this.media.play(!isPlayEmit));
14663
- case 7:
13728
+ case 5:
14664
13729
  case "end":
14665
13730
  return _context6.stop();
14666
13731
  }
14667
13732
  }, _callee6, this);
14668
13733
  }));
14669
- function replay(_x2) {
13734
+ function replay(_x3) {
14670
13735
  return _replay.apply(this, arguments);
14671
13736
  }
14672
13737
  return replay;
@@ -14771,7 +13836,7 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
14771
13836
  }
14772
13837
  }, _callee7, this, [[18, 29]]);
14773
13838
  }));
14774
- function switchURL(_x3) {
13839
+ function switchURL(_x4) {
14775
13840
  return _switchURL.apply(this, arguments);
14776
13841
  }
14777
13842
  return switchURL;
@@ -14857,7 +13922,7 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
14857
13922
  }
14858
13923
  }, _callee8, this, [[8, 16], [21, 31]]);
14859
13924
  }));
14860
- function switchStream(_x4) {
13925
+ function switchStream(_x5) {
14861
13926
  return _switchStream.apply(this, arguments);
14862
13927
  }
14863
13928
  return switchStream;
@@ -14943,7 +14008,7 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
14943
14008
  }
14944
14009
  }, _callee9, this, [[10, 18], [22, 32]]);
14945
14010
  }));
14946
- function switchAudioStream(_x5) {
14011
+ function switchAudioStream(_x6) {
14947
14012
  return _switchAudioStream.apply(this, arguments);
14948
14013
  }
14949
14014
  return switchAudioStream;
@@ -14968,50 +14033,25 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
14968
14033
  }
14969
14034
  }, _callee10, this);
14970
14035
  }));
14971
- function switchSubtitleStream(_x6) {
14036
+ function switchSubtitleStream(_x7) {
14972
14037
  return _switchSubtitleStream.apply(this, arguments);
14973
14038
  }
14974
14039
  return switchSubtitleStream;
14975
14040
  }()
14976
- }, {
14977
- key: "detachMedia",
14978
- value: function() {
14979
- var _detachMedia = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee11() {
14980
- return _regeneratorRuntime$1().wrap(function _callee11$(_context11) {
14981
- while (1)
14982
- switch (_context11.prev = _context11.next) {
14983
- case 0:
14984
- if (!this._bufferService) {
14985
- _context11.next = 3;
14986
- break;
14987
- }
14988
- _context11.next = 3;
14989
- return this._bufferService.detachMedia();
14990
- case 3:
14991
- case "end":
14992
- return _context11.stop();
14993
- }
14994
- }, _callee11, this);
14995
- }));
14996
- function detachMedia() {
14997
- return _detachMedia.apply(this, arguments);
14998
- }
14999
- return detachMedia;
15000
- }()
15001
14041
  }, {
15002
14042
  key: "destroy",
15003
14043
  value: function() {
15004
- var _destroy = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee12() {
14044
+ var _destroy = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee11() {
15005
14045
  var _this$_seiService2;
15006
- return _regeneratorRuntime$1().wrap(function _callee12$(_context12) {
14046
+ return _regeneratorRuntime$1().wrap(function _callee11$(_context11) {
15007
14047
  while (1)
15008
- switch (_context12.prev = _context12.next) {
14048
+ switch (_context11.prev = _context11.next) {
15009
14049
  case 0:
15010
14050
  if (this.media) {
15011
- _context12.next = 2;
14051
+ _context11.next = 2;
15012
14052
  break;
15013
14053
  }
15014
- return _context12.abrupt("return");
14054
+ return _context11.abrupt("return");
15015
14055
  case 2:
15016
14056
  this.removeAllListeners();
15017
14057
  this._playlist.reset();
@@ -15022,15 +14062,15 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
15022
14062
  this.media.removeEventListener("pause", this._onPause);
15023
14063
  this.media.removeEventListener("seeking", this._onSeeking);
15024
14064
  this.media.removeEventListener("timeupdate", this._onTimeupdate);
15025
- _context12.next = 13;
14065
+ _context11.next = 13;
15026
14066
  return Promise.all([this._clear(), this._bufferService.destroy()]);
15027
14067
  case 13:
15028
14068
  this.media = null;
15029
14069
  case 14:
15030
14070
  case "end":
15031
- return _context12.stop();
14071
+ return _context11.stop();
15032
14072
  }
15033
- }, _callee12, this);
14073
+ }, _callee11, this);
15034
14074
  }));
15035
14075
  function destroy() {
15036
14076
  return _destroy.apply(this, arguments);
@@ -15040,48 +14080,48 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
15040
14080
  }, {
15041
14081
  key: "_loadM3U8",
15042
14082
  value: function() {
15043
- var _loadM3U = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee13(url) {
14083
+ var _loadM3U = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee12(url) {
15044
14084
  var playlist, _this$config$manifest, _this$config$manifest2, manifest, _ref4, _ref5, _this$_playlist$curre;
15045
- return _regeneratorRuntime$1().wrap(function _callee13$(_context13) {
14085
+ return _regeneratorRuntime$1().wrap(function _callee12$(_context12) {
15046
14086
  while (1)
15047
- switch (_context13.prev = _context13.next) {
14087
+ switch (_context12.prev = _context12.next) {
15048
14088
  case 0:
15049
- _context13.prev = 0;
14089
+ _context12.prev = 0;
15050
14090
  manifest = (_this$config$manifest = this.config.manifestList) === null || _this$config$manifest === void 0 ? void 0 : (_this$config$manifest2 = _this$config$manifest.filter(function(x) {
15051
14091
  return x.url === url;
15052
14092
  })[0]) === null || _this$config$manifest2 === void 0 ? void 0 : _this$config$manifest2.manifest;
15053
14093
  if (!manifest) {
15054
- _context13.next = 6;
14094
+ _context12.next = 6;
15055
14095
  break;
15056
14096
  }
15057
- _context13.t0 = this._manifestLoader.parseText(manifest, url);
15058
- _context13.next = 9;
14097
+ _context12.t0 = this._manifestLoader.parseText(manifest, url);
14098
+ _context12.next = 9;
15059
14099
  break;
15060
14100
  case 6:
15061
- _context13.next = 8;
14101
+ _context12.next = 8;
15062
14102
  return this._manifestLoader.load(url);
15063
14103
  case 8:
15064
- _context13.t0 = _context13.sent;
14104
+ _context12.t0 = _context12.sent;
15065
14105
  case 9:
15066
- _ref4 = _context13.t0;
14106
+ _ref4 = _context12.t0;
15067
14107
  _ref5 = _slicedToArray$1(_ref4, 1);
15068
14108
  playlist = _ref5[0];
15069
- _context13.next = 17;
14109
+ _context12.next = 17;
15070
14110
  break;
15071
14111
  case 14:
15072
- _context13.prev = 14;
15073
- _context13.t1 = _context13["catch"](0);
15074
- throw this._emitError(StreamingError.create(_context13.t1));
14112
+ _context12.prev = 14;
14113
+ _context12.t1 = _context12["catch"](0);
14114
+ throw this._emitError(StreamingError.create(_context12.t1));
15075
14115
  case 17:
15076
14116
  if (playlist) {
15077
- _context13.next = 19;
14117
+ _context12.next = 19;
15078
14118
  break;
15079
14119
  }
15080
- return _context13.abrupt("return");
14120
+ return _context12.abrupt("return");
15081
14121
  case 19:
15082
14122
  this._playlist.upsertPlaylist(playlist);
15083
14123
  if (!playlist.isMaster) {
15084
- _context13.next = 24;
14124
+ _context12.next = 24;
15085
14125
  break;
15086
14126
  }
15087
14127
  if ((_this$_playlist$curre = this._playlist.currentStream.subtitleStreams) !== null && _this$_playlist$curre !== void 0 && _this$_playlist$curre.length) {
@@ -15089,18 +14129,18 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
15089
14129
  list: this._playlist.currentStream.subtitleStreams
15090
14130
  });
15091
14131
  }
15092
- _context13.next = 24;
14132
+ _context12.next = 24;
15093
14133
  return this._refreshM3U8();
15094
14134
  case 24:
15095
14135
  this.emit(Event$1.STREAM_PARSED);
15096
- return _context13.abrupt("return", playlist);
14136
+ return _context12.abrupt("return", playlist);
15097
14137
  case 26:
15098
14138
  case "end":
15099
- return _context13.stop();
14139
+ return _context12.stop();
15100
14140
  }
15101
- }, _callee13, this, [[0, 14]]);
14141
+ }, _callee12, this, [[0, 14]]);
15102
14142
  }));
15103
- function _loadM3U8(_x7) {
14143
+ function _loadM3U8(_x8) {
15104
14144
  return _loadM3U.apply(this, arguments);
15105
14145
  }
15106
14146
  return _loadM3U8;
@@ -15134,7 +14174,7 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
15134
14174
  var isEmpty = this._playlist.isEmpty;
15135
14175
  var pollInterval;
15136
14176
  if (this._playlist.lowLatency) {
15137
- pollInterval = (this._playlist.currentStream.partTargetDuration || 0) * 1e3;
14177
+ pollInterval = (this._playlist.currentStream.partTargetDuration * 2 || 0) * 1e3;
15138
14178
  } else {
15139
14179
  var _this$_playlist$lastS;
15140
14180
  pollInterval = (((_this$_playlist$lastS = this._playlist.lastSegment) === null || _this$_playlist$lastS === void 0 ? void 0 : _this$_playlist$lastS.duration) || 0) * 1e3;
@@ -15162,53 +14202,53 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
15162
14202
  }, {
15163
14203
  key: "_loadSegmentDirect",
15164
14204
  value: function() {
15165
- var _loadSegmentDirect2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee14(loadOnce) {
14205
+ var _loadSegmentDirect2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee13(loadOnce) {
15166
14206
  var seg, appended, cachedError, _this$_playlist$curre2, bufferEnd, sameStream;
15167
- return _regeneratorRuntime$1().wrap(function _callee14$(_context14) {
14207
+ return _regeneratorRuntime$1().wrap(function _callee13$(_context13) {
15168
14208
  while (1)
15169
- switch (_context14.prev = _context14.next) {
14209
+ switch (_context13.prev = _context13.next) {
15170
14210
  case 0:
15171
14211
  seg = this._playlist.nextSegment;
15172
14212
  if (seg) {
15173
- _context14.next = 3;
14213
+ _context13.next = 3;
15174
14214
  break;
15175
14215
  }
15176
- return _context14.abrupt("return");
14216
+ return _context13.abrupt("return");
15177
14217
  case 3:
15178
14218
  appended = false;
15179
14219
  cachedError = null;
15180
- _context14.prev = 5;
14220
+ _context13.prev = 5;
15181
14221
  this._segmentProcessing = true;
15182
14222
  logger.log("load segment, sn:".concat(seg.sn, ", [").concat(seg.start, ", ").concat(seg.end, "], partIndex:").concat(seg.partIndex));
15183
- _context14.next = 10;
14223
+ _context13.next = 10;
15184
14224
  return this._reqAndBufferSegment(seg, this._playlist.getAudioSegment(seg));
15185
14225
  case 10:
15186
- appended = _context14.sent;
15187
- _context14.next = 16;
14226
+ appended = _context13.sent;
14227
+ _context13.next = 16;
15188
14228
  break;
15189
14229
  case 13:
15190
- _context14.prev = 13;
15191
- _context14.t0 = _context14["catch"](5);
15192
- cachedError = _context14.t0;
14230
+ _context13.prev = 13;
14231
+ _context13.t0 = _context13["catch"](5);
14232
+ cachedError = _context13.t0;
15193
14233
  case 16:
15194
- _context14.prev = 16;
14234
+ _context13.prev = 16;
15195
14235
  this._segmentProcessing = false;
15196
- return _context14.finish(16);
14236
+ return _context13.finish(16);
15197
14237
  case 19:
15198
14238
  if (!cachedError) {
15199
- _context14.next = 26;
14239
+ _context13.next = 26;
15200
14240
  break;
15201
14241
  }
15202
14242
  if (!this._bufferService.isFull()) {
15203
- _context14.next = 25;
14243
+ _context13.next = 25;
15204
14244
  break;
15205
14245
  }
15206
14246
  logger.log("load segment, sn:".concat(seg.sn, ", partIndex:").concat(seg.partIndex));
15207
14247
  this._segmentProcessing = true;
15208
14248
  this._isProcessQuotaExceeded = true;
15209
- return _context14.abrupt("return", false);
14249
+ return _context13.abrupt("return", false);
15210
14250
  case 25:
15211
- return _context14.abrupt("return", this._emitError(StreamingError.create(cachedError)));
14251
+ return _context13.abrupt("return", this._emitError(StreamingError.create(cachedError)));
15212
14252
  case 26:
15213
14253
  if (appended) {
15214
14254
  bufferEnd = this.bufferInfo().end;
@@ -15234,14 +14274,14 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
15234
14274
  this._loadSegment();
15235
14275
  }
15236
14276
  }
15237
- return _context14.abrupt("return", appended);
14277
+ return _context13.abrupt("return", appended);
15238
14278
  case 28:
15239
14279
  case "end":
15240
- return _context14.stop();
14280
+ return _context13.stop();
15241
14281
  }
15242
- }, _callee14, this, [[5, 13, 16, 19]]);
14282
+ }, _callee13, this, [[5, 13, 16, 19]]);
15243
14283
  }));
15244
- function _loadSegmentDirect(_x8) {
14284
+ function _loadSegmentDirect(_x9) {
15245
14285
  return _loadSegmentDirect2.apply(this, arguments);
15246
14286
  }
15247
14287
  return _loadSegmentDirect;
@@ -15249,45 +14289,45 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
15249
14289
  }, {
15250
14290
  key: "_reqAndBufferSegment",
15251
14291
  value: function() {
15252
- var _reqAndBufferSegment2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee15(seg, audioSeg) {
14292
+ var _reqAndBufferSegment2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee14(seg, audioSeg) {
15253
14293
  var _this$_bufferService2;
15254
14294
  var cc, discontinuity, responses, data, sn, start, stream, before, contiguous, segStart;
15255
- return _regeneratorRuntime$1().wrap(function _callee15$(_context15) {
14295
+ return _regeneratorRuntime$1().wrap(function _callee14$(_context14) {
15256
14296
  while (1)
15257
- switch (_context15.prev = _context15.next) {
14297
+ switch (_context14.prev = _context14.next) {
15258
14298
  case 0:
15259
14299
  cc = seg ? seg.cc : audioSeg.cc;
15260
14300
  discontinuity = this._prevSegCc !== cc;
15261
14301
  responses = [];
15262
- _context15.prev = 3;
15263
- _context15.next = 6;
14302
+ _context14.prev = 3;
14303
+ _context14.next = 6;
15264
14304
  return this._segmentLoader.load(seg, audioSeg, discontinuity);
15265
14305
  case 6:
15266
- responses = _context15.sent;
15267
- _context15.next = 14;
14306
+ responses = _context14.sent;
14307
+ _context14.next = 14;
15268
14308
  break;
15269
14309
  case 9:
15270
- _context15.prev = 9;
15271
- _context15.t0 = _context15["catch"](3);
15272
- _context15.t0.fatal = false;
15273
- this._segmentLoader.error = _context15.t0;
15274
- throw _context15.t0;
14310
+ _context14.prev = 9;
14311
+ _context14.t0 = _context14["catch"](3);
14312
+ _context14.t0.fatal = false;
14313
+ this._segmentLoader.error = _context14.t0;
14314
+ throw _context14.t0;
15275
14315
  case 14:
15276
14316
  if (responses[0]) {
15277
- _context15.next = 16;
14317
+ _context14.next = 16;
15278
14318
  break;
15279
14319
  }
15280
- return _context15.abrupt("return");
14320
+ return _context14.abrupt("return");
15281
14321
  case 16:
15282
- _context15.next = 18;
14322
+ _context14.next = 18;
15283
14323
  return (_this$_bufferService2 = this._bufferService).decryptBuffer.apply(_this$_bufferService2, _toConsumableArray$2(responses));
15284
14324
  case 18:
15285
- data = _context15.sent;
14325
+ data = _context14.sent;
15286
14326
  if (data) {
15287
- _context15.next = 21;
14327
+ _context14.next = 21;
15288
14328
  break;
15289
14329
  }
15290
- return _context15.abrupt("return");
14330
+ return _context14.abrupt("return");
15291
14331
  case 21:
15292
14332
  sn = seg ? seg.sn : audioSeg.sn;
15293
14333
  start = seg ? seg.start : audioSeg.start;
@@ -15301,26 +14341,26 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
15301
14341
  logger.warn("update the new playlist liveEdge, segment id=".concat(sn, ", buffer start=").concat(segStart, ", liveEdge=").concat(this._playlist.liveEdge));
15302
14342
  start = segStart;
15303
14343
  }
15304
- _context15.next = 30;
14344
+ _context14.next = 30;
15305
14345
  return this._bufferService.appendBuffer(seg, audioSeg, data[0], data[1], discontinuity, contiguous, start);
15306
14346
  case 30:
15307
14347
  this.emit(Event$1.APPEND_COST, {
15308
14348
  elapsed: Date.now() - before,
15309
14349
  url: seg.url
15310
14350
  });
15311
- _context15.next = 33;
14351
+ _context14.next = 33;
15312
14352
  return this._bufferService.evictBuffer(this.config.bufferBehind);
15313
14353
  case 33:
15314
14354
  this._prevSegCc = cc;
15315
14355
  this._prevSegSn = sn;
15316
- return _context15.abrupt("return", true);
14356
+ return _context14.abrupt("return", true);
15317
14357
  case 36:
15318
14358
  case "end":
15319
- return _context15.stop();
14359
+ return _context14.stop();
15320
14360
  }
15321
- }, _callee15, this, [[3, 9]]);
14361
+ }, _callee14, this, [[3, 9]]);
15322
14362
  }));
15323
- function _reqAndBufferSegment(_x9, _x10) {
14363
+ function _reqAndBufferSegment(_x10, _x11) {
15324
14364
  return _reqAndBufferSegment2.apply(this, arguments);
15325
14365
  }
15326
14366
  return _reqAndBufferSegment;
@@ -15328,11 +14368,11 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
15328
14368
  }, {
15329
14369
  key: "_onCheckQuotaExceeded",
15330
14370
  value: function() {
15331
- var _onCheckQuotaExceeded2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee16() {
14371
+ var _onCheckQuotaExceeded2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee15() {
15332
14372
  var seekTime, buffered, inBuffered, i, bufferBehind, mediaTime;
15333
- return _regeneratorRuntime$1().wrap(function _callee16$(_context16) {
14373
+ return _regeneratorRuntime$1().wrap(function _callee15$(_context15) {
15334
14374
  while (1)
15335
- switch (_context16.prev = _context16.next) {
14375
+ switch (_context15.prev = _context15.next) {
15336
14376
  case 0:
15337
14377
  seekTime = this.media.currentTime;
15338
14378
  buffered = this.media.buffered;
@@ -15340,37 +14380,37 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
15340
14380
  i = 0;
15341
14381
  case 4:
15342
14382
  if (!(i < buffered.length)) {
15343
- _context16.next = 11;
14383
+ _context15.next = 11;
15344
14384
  break;
15345
14385
  }
15346
14386
  if (!(buffered.start(0) >= seekTime && seekTime < buffered.end(i))) {
15347
- _context16.next = 8;
14387
+ _context15.next = 8;
15348
14388
  break;
15349
14389
  }
15350
14390
  inBuffered = true;
15351
- return _context16.abrupt("break", 11);
14391
+ return _context15.abrupt("break", 11);
15352
14392
  case 8:
15353
14393
  i++;
15354
- _context16.next = 4;
14394
+ _context15.next = 4;
15355
14395
  break;
15356
14396
  case 11:
15357
14397
  if (!this._bufferService.isFull()) {
15358
- _context16.next = 17;
14398
+ _context15.next = 17;
15359
14399
  break;
15360
14400
  }
15361
14401
  bufferBehind = inBuffered ? this.config.bufferBehind : 5;
15362
14402
  mediaTime = this.media.currentTime;
15363
14403
  if (!(mediaTime - bufferBehind > 0)) {
15364
- _context16.next = 17;
14404
+ _context15.next = 17;
15365
14405
  break;
15366
14406
  }
15367
- _context16.next = 17;
14407
+ _context15.next = 17;
15368
14408
  return this._bufferService.removeBuffer(0, mediaTime - bufferBehind);
15369
14409
  case 17:
15370
14410
  case "end":
15371
- return _context16.stop();
14411
+ return _context15.stop();
15372
14412
  }
15373
- }, _callee16, this);
14413
+ }, _callee15, this);
15374
14414
  }));
15375
14415
  function _onCheckQuotaExceeded() {
15376
14416
  return _onCheckQuotaExceeded2.apply(this, arguments);
@@ -15388,22 +14428,22 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
15388
14428
  }, {
15389
14429
  key: "_clear",
15390
14430
  value: function() {
15391
- var _clear2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee17() {
15392
- return _regeneratorRuntime$1().wrap(function _callee17$(_context17) {
14431
+ var _clear2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee16() {
14432
+ return _regeneratorRuntime$1().wrap(function _callee16$(_context16) {
15393
14433
  while (1)
15394
- switch (_context17.prev = _context17.next) {
14434
+ switch (_context16.prev = _context16.next) {
15395
14435
  case 0:
15396
14436
  clearTimeout(this._disconnectTimer);
15397
14437
  this._stopTick();
15398
- _context17.next = 4;
14438
+ _context16.next = 4;
15399
14439
  return Promise.all([this._segmentLoader.cancel(), this._manifestLoader.stopPoll()]);
15400
14440
  case 4:
15401
14441
  this._segmentProcessing = false;
15402
14442
  case 5:
15403
14443
  case "end":
15404
- return _context17.stop();
14444
+ return _context16.stop();
15405
14445
  }
15406
- }, _callee17, this);
14446
+ }, _callee16, this);
15407
14447
  }));
15408
14448
  function _clear() {
15409
14449
  return _clear2.apply(this, arguments);
@@ -15413,14 +14453,14 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
15413
14453
  }, {
15414
14454
  key: "_reset",
15415
14455
  value: function() {
15416
- var _reset2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee18() {
14456
+ var _reset2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee17() {
15417
14457
  var _this$_seiService3;
15418
- var reuseMse, _args18 = arguments;
15419
- return _regeneratorRuntime$1().wrap(function _callee18$(_context18) {
14458
+ var reuseMse, _args17 = arguments;
14459
+ return _regeneratorRuntime$1().wrap(function _callee17$(_context17) {
15420
14460
  while (1)
15421
- switch (_context18.prev = _context18.next) {
14461
+ switch (_context17.prev = _context17.next) {
15422
14462
  case 0:
15423
- reuseMse = _args18.length > 0 && _args18[0] !== void 0 ? _args18[0] : false;
14463
+ reuseMse = _args17.length > 0 && _args17[0] !== void 0 ? _args17[0] : false;
15424
14464
  this._reloadOnPlay = false;
15425
14465
  this._prevSegSn = null;
15426
14466
  this._prevSegCc = null;
@@ -15429,15 +14469,15 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
15429
14469
  this._segmentLoader.reset();
15430
14470
  (_this$_seiService3 = this._seiService) === null || _this$_seiService3 === void 0 ? void 0 : _this$_seiService3.reset();
15431
14471
  this._stats.reset();
15432
- _context18.next = 11;
14472
+ _context17.next = 11;
15433
14473
  return this._clear();
15434
14474
  case 11:
15435
- return _context18.abrupt("return", this._bufferService.reset(reuseMse));
14475
+ return _context17.abrupt("return", this._bufferService.reset(reuseMse));
15436
14476
  case 12:
15437
14477
  case "end":
15438
- return _context18.stop();
14478
+ return _context17.stop();
15439
14479
  }
15440
- }, _callee18, this);
14480
+ }, _callee17, this);
15441
14481
  }));
15442
14482
  function _reset() {
15443
14483
  return _reset2.apply(this, arguments);
@@ -15518,8 +14558,8 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
15518
14558
  value: function _tryEos() {
15519
14559
  var _this$_bufferService3, _this$_bufferService4;
15520
14560
  var media = this.media;
15521
- var _this$_playlist2 = this._playlist, nextSegment = _this$_playlist2.nextSegment, lastSegment = _this$_playlist2.lastSegment;
15522
- var eosAllowed = (!nextSegment || lastSegment && Buffer$1.isBuffered(media, lastSegment.start + lastSegment.duration / 2)) && media.readyState && media.duration > 0 && ((_this$_bufferService3 = this._bufferService) === null || _this$_bufferService3 === void 0 ? void 0 : _this$_bufferService3.msIsOpened) && !((_this$_bufferService4 = this._bufferService) !== null && _this$_bufferService4 !== void 0 && _this$_bufferService4.msHasOpTasks);
14561
+ var _this$_playlist = this._playlist, nextSegment = _this$_playlist.nextSegment, lastSegment = _this$_playlist.lastSegment;
14562
+ var eosAllowed = !nextSegment && media.readyState && media.duration > 0 && ((_this$_bufferService3 = this._bufferService) === null || _this$_bufferService3 === void 0 ? void 0 : _this$_bufferService3.msIsOpened) && !((_this$_bufferService4 = this._bufferService) !== null && _this$_bufferService4 !== void 0 && _this$_bufferService4.msHasOpTasks);
15523
14563
  if (!eosAllowed) {
15524
14564
  return;
15525
14565
  }
@@ -15555,7 +14595,7 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
15555
14595
  }]);
15556
14596
  return Hls2;
15557
14597
  }(EventEmitter);
15558
- _defineProperty$3(Hls, "version", "3.0.20-alpha.3");
14598
+ _defineProperty$3(Hls, "version", "3.0.19-rc.0");
15559
14599
  try {
15560
14600
  if (localStorage.getItem("xgd")) {
15561
14601
  Hls.enableLogger();
@@ -15646,7 +14686,6 @@ var PluginExtension = /* @__PURE__ */ function() {
15646
14686
  }]);
15647
14687
  return PluginExtension2;
15648
14688
  }();
15649
- var _excluded = ["currentTime"];
15650
14689
  function parseSwitchUrlArgs(args, plugin) {
15651
14690
  var player = plugin.player;
15652
14691
  var curTime = player.currentTime;
@@ -15657,14 +14696,9 @@ function parseSwitchUrlArgs(args, plugin) {
15657
14696
  case "boolean":
15658
14697
  options.seamless = args;
15659
14698
  break;
15660
- case "object": {
15661
- var currentTime = args.currentTime, rest = _objectWithoutProperties$1(args, _excluded);
15662
- Object.assign(options, rest);
15663
- if (typeof currentTime === "number") {
15664
- options.startTime = currentTime;
15665
- }
14699
+ case "object":
14700
+ Object.assign(options, args);
15666
14701
  break;
15667
- }
15668
14702
  }
15669
14703
  return options;
15670
14704
  }
@@ -15674,11 +14708,10 @@ var HlsPlugin = /* @__PURE__ */ function(_BasePlugin) {
15674
14708
  function HlsPlugin2() {
15675
14709
  var _this;
15676
14710
  _classCallCheck$3(this, HlsPlugin2);
15677
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
15678
- args[_key] = arguments[_key];
14711
+ for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
14712
+ _args[_key] = arguments[_key];
15679
14713
  }
15680
- _this = _super.call.apply(_super, [this].concat(args));
15681
- _defineProperty$3(_assertThisInitialized$2(_this), "logger", logger);
14714
+ _this = _super.call.apply(_super, [this].concat(_args));
15682
14715
  _defineProperty$3(_assertThisInitialized$2(_this), "hls", null);
15683
14716
  _defineProperty$3(_assertThisInitialized$2(_this), "pluginExtension", null);
15684
14717
  _defineProperty$3(_assertThisInitialized$2(_this), "getStats", function() {
@@ -15690,6 +14723,24 @@ var HlsPlugin = /* @__PURE__ */ function(_BasePlugin) {
15690
14723
  var lang = _ref.lang;
15691
14724
  (_this$hls2 = _this.hls) === null || _this$hls2 === void 0 ? void 0 : _this$hls2.switchSubtitleStream(lang);
15692
14725
  });
14726
+ _defineProperty$3(_assertThisInitialized$2(_this), "_onSwitchURL", function(url, args) {
14727
+ return new Promise(function(resolve, reject) {
14728
+ var _assertThisInitialize = _assertThisInitialized$2(_this), player = _assertThisInitialize.player, hls = _assertThisInitialize.hls;
14729
+ if (hls) {
14730
+ var _this$player$config, _this$player$config$h;
14731
+ var options = parseSwitchUrlArgs(args, _assertThisInitialized$2(_this));
14732
+ player.config.url = url;
14733
+ hls.switchURL(url, options).then(function() {
14734
+ return resolve(true);
14735
+ }).catch(reject);
14736
+ if (!options.seamless && (_this$player$config = _this.player.config) !== null && _this$player$config !== void 0 && (_this$player$config$h = _this$player$config.hls) !== null && _this$player$config$h !== void 0 && _this$player$config$h.keepStatusAfterSwitch) {
14737
+ _this._keepPauseStatus();
14738
+ }
14739
+ } else {
14740
+ reject();
14741
+ }
14742
+ });
14743
+ });
15693
14744
  _defineProperty$3(_assertThisInitialized$2(_this), "_keepPauseStatus", function() {
15694
14745
  var paused = _this.player.paused;
15695
14746
  if (!paused)
@@ -15714,8 +14765,8 @@ var HlsPlugin = /* @__PURE__ */ function(_BasePlugin) {
15714
14765
  }, {
15715
14766
  key: "softDecode",
15716
14767
  get: function get() {
15717
- var _this$player, _this$player$config;
15718
- var mediaType = (_this$player = this.player) === null || _this$player === void 0 ? void 0 : (_this$player$config = _this$player.config) === null || _this$player$config === void 0 ? void 0 : _this$player$config.mediaType;
14768
+ var _this$player, _this$player$config2;
14769
+ var mediaType = (_this$player = this.player) === null || _this$player === void 0 ? void 0 : (_this$player$config2 = _this$player.config) === null || _this$player$config2 === void 0 ? void 0 : _this$player$config2.mediaType;
15719
14770
  return !!mediaType && mediaType !== "video" && mediaType !== "audio";
15720
14771
  }
15721
14772
  }, {
@@ -15723,35 +14774,13 @@ var HlsPlugin = /* @__PURE__ */ function(_BasePlugin) {
15723
14774
  value: function beforePlayerInit() {
15724
14775
  var _this2 = this;
15725
14776
  var config = this.player.config;
15726
- var mediaElem = this.player.media || this.player.video;
15727
14777
  var hlsOpts = config.hls || {};
15728
14778
  if (!config.url && !config.__allowHlsEmptyUrl__ || !hlsOpts.preferMMS && MSE.isMMSOnly()) {
15729
14779
  return;
15730
14780
  }
15731
14781
  if (this.hls)
15732
14782
  this.hls.destroy();
15733
- var descriptor = Object.getOwnPropertyDescriptor(this.player, "switchURL");
15734
- if (!descriptor || descriptor.writable) {
15735
- this.player.switchURL = function(url, args) {
15736
- return new Promise(function(resolve, reject) {
15737
- var player = _this2.player, hls = _this2.hls;
15738
- if (hls) {
15739
- var _this2$player$config, _this2$player$config$;
15740
- var options = parseSwitchUrlArgs(args, _this2);
15741
- player.config.url = url;
15742
- hls.switchURL(url, options).then(function() {
15743
- return resolve(true);
15744
- }).catch(reject);
15745
- if (!options.seamless && (_this2$player$config = _this2.player.config) !== null && _this2$player$config !== void 0 && (_this2$player$config$ = _this2$player$config.hls) !== null && _this2$player$config$ !== void 0 && _this2$player$config$.keepStatusAfterSwitch) {
15746
- _this2._keepPauseStatus();
15747
- }
15748
- } else {
15749
- reject();
15750
- }
15751
- });
15752
- };
15753
- }
15754
- var onSwitchUrl = this.player.switchURL;
14783
+ this.player.switchURL = this._onSwitchURL;
15755
14784
  this.player.handleSource = false;
15756
14785
  hlsOpts.innerDegrade = hlsOpts.innerDegrade || config.innerDegrade;
15757
14786
  if (hlsOpts.disconnectTime === null || hlsOpts.disconnectTime === void 0)
@@ -15759,7 +14788,7 @@ var HlsPlugin = /* @__PURE__ */ function(_BasePlugin) {
15759
14788
  this.hls = new Hls(_objectSpread2$2({
15760
14789
  softDecode: this.softDecode,
15761
14790
  isLive: config.isLive,
15762
- media: mediaElem,
14791
+ media: this.player.media || this.player.video,
15763
14792
  startTime: config.startTime,
15764
14793
  url: config.url
15765
14794
  }, hlsOpts));
@@ -15777,7 +14806,7 @@ var HlsPlugin = /* @__PURE__ */ function(_BasePlugin) {
15777
14806
  if (this.softDecode) {
15778
14807
  this.pluginExtension = new PluginExtension(_objectSpread2$2({
15779
14808
  isLive: config.isLive,
15780
- media: mediaElem
14809
+ media: this.player.video
15781
14810
  }, hlsOpts), this);
15782
14811
  this.player.forceDegradeToVideo = function() {
15783
14812
  var _this2$pluginExtensio;
@@ -15794,8 +14823,8 @@ var HlsPlugin = /* @__PURE__ */ function(_BasePlugin) {
15794
14823
  return (_this2$hls2 = _this2.hls) === null || _this2$hls2 === void 0 ? void 0 : _this2$hls2.replay();
15795
14824
  });
15796
14825
  }
15797
- this.on(URL_CHANGE, onSwitchUrl);
15798
14826
  this.on(SWITCH_SUBTITLE, this._onSwitchSubtitle);
14827
+ this.on(URL_CHANGE, this._onSwitchURL);
15799
14828
  this.on(DESTROY, this.destroy.bind(this));
15800
14829
  this._transError();
15801
14830
  this._transCoreEvent(EVENT.TTFB);
@@ -15805,7 +14834,6 @@ var HlsPlugin = /* @__PURE__ */ function(_BasePlugin) {
15805
14834
  this._transCoreEvent(EVENT.LOAD_RETRY);
15806
14835
  this._transCoreEvent(EVENT.SOURCEBUFFER_CREATED);
15807
14836
  this._transCoreEvent(EVENT.MEDIASOURCE_OPENED);
15808
- this._transCoreEvent(EVENT.APPEND_BUFFER);
15809
14837
  this._transCoreEvent(EVENT.REMOVE_BUFFER);
15810
14838
  this._transCoreEvent(EVENT.BUFFEREOS);
15811
14839
  this._transCoreEvent(EVENT.KEYFRAME);
@@ -15825,9 +14853,7 @@ var HlsPlugin = /* @__PURE__ */ function(_BasePlugin) {
15825
14853
  this._transCoreEvent(Event$1.SUBTITLE_PLAYLIST);
15826
14854
  this._transCoreEvent(Event$1.APPEND_COST);
15827
14855
  if (config.url) {
15828
- this.hls.load(config.url, {
15829
- reuseMse: true
15830
- }).catch(function(e) {
14856
+ this.hls.load(config.url, true).catch(function(e) {
15831
14857
  });
15832
14858
  }
15833
14859
  }