@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
@@ -1644,7 +1644,7 @@
1644
1644
  }
1645
1645
  return offsetTime;
1646
1646
  };
1647
- var version = "3.0.20-rc.6";
1647
+ var version = "3.0.19-rc.0";
1648
1648
  var ERROR_MAP = {
1649
1649
  1: 5101,
1650
1650
  2: 5102,
@@ -1753,7 +1753,8 @@
1753
1753
  }
1754
1754
  if (this.__hooks && this.__hooks[hookName]) {
1755
1755
  try {
1756
- var preRet = runHooks(this, hookName, handler);
1756
+ var _this$__hooks$hookNam;
1757
+ var preRet = (_this$__hooks$hookNam = this.__hooks[hookName]).call.apply(_this$__hooks$hookNam, [this, this].concat(Array.prototype.slice.call(arguments)));
1757
1758
  if (preRet) {
1758
1759
  if (preRet.then) {
1759
1760
  preRet.then(function(isContinue) {
@@ -1778,19 +1779,6 @@
1778
1779
  }
1779
1780
  }.bind(this);
1780
1781
  }
1781
- function findHookIndex(hookName, handler) {
1782
- var __hooks = this.__hooks;
1783
- if (!__hooks || !Array.isArray(__hooks[hookName])) {
1784
- return -1;
1785
- }
1786
- var hookHandlers = __hooks[hookName];
1787
- for (var i = 0; i < hookHandlers.length; i++) {
1788
- if (hookHandlers[i] === handler) {
1789
- return i;
1790
- }
1791
- }
1792
- return -1;
1793
- }
1794
1782
  function useHooks(hookName, handler) {
1795
1783
  var __hooks = this.__hooks;
1796
1784
  if (!__hooks) {
@@ -1800,12 +1788,7 @@
1800
1788
  console.warn("has no supported hook which name [".concat(hookName, "]"));
1801
1789
  return false;
1802
1790
  }
1803
- if (!Array.isArray(__hooks[hookName])) {
1804
- __hooks[hookName] = [];
1805
- }
1806
- if (findHookIndex.call(this, hookName, handler) === -1) {
1807
- __hooks[hookName].push(handler);
1808
- }
1791
+ __hooks && (__hooks[hookName] = handler);
1809
1792
  return true;
1810
1793
  }
1811
1794
  function removeHooks(hookName, handler) {
@@ -1813,13 +1796,6 @@
1813
1796
  if (!__hooks) {
1814
1797
  return;
1815
1798
  }
1816
- if (Array.isArray(__hooks[hookName])) {
1817
- var hooks = __hooks[hookName];
1818
- var index = findHookIndex.call(this, hookName, handler);
1819
- if (index !== -1) {
1820
- hooks.splice(index, 1);
1821
- }
1822
- }
1823
1799
  delete __hooks[hookName];
1824
1800
  }
1825
1801
  function hooksDescriptor(instance) {
@@ -1841,38 +1817,6 @@
1841
1817
  function delHooksDescriptor(instance) {
1842
1818
  instance.__hooks = null;
1843
1819
  }
1844
- function runHooks(obj, hookName, handler) {
1845
- for (var _len5 = arguments.length, args = new Array(_len5 > 3 ? _len5 - 3 : 0), _key5 = 3; _key5 < _len5; _key5++) {
1846
- args[_key5 - 3] = arguments[_key5];
1847
- }
1848
- if (obj.__hooks && Array.isArray(obj.__hooks[hookName])) {
1849
- var hooks = obj.__hooks[hookName];
1850
- var index = -1;
1851
- var runHooksRecursive = function runHooksRecursive2(obj2, hookName2, handler2) {
1852
- for (var _len6 = arguments.length, args2 = new Array(_len6 > 3 ? _len6 - 3 : 0), _key6 = 3; _key6 < _len6; _key6++) {
1853
- args2[_key6 - 3] = arguments[_key6];
1854
- }
1855
- index++;
1856
- if (hooks.length === 0 || index === hooks.length) {
1857
- return handler2.call.apply(handler2, [obj2, obj2].concat(args2));
1858
- }
1859
- var hook2 = hooks[index];
1860
- var ret = hook2.call.apply(hook2, [obj2, obj2].concat(args2));
1861
- if (ret && ret.then) {
1862
- return ret.then(function(data) {
1863
- return data === false ? null : runHooksRecursive2.apply(void 0, [obj2, hookName2, handler2].concat(args2));
1864
- }).catch(function(e) {
1865
- console.warn("[runHooks]".concat(hookName2, " reject"), e.message);
1866
- });
1867
- } else if (ret !== false) {
1868
- return runHooksRecursive2.apply(void 0, [obj2, hookName2, handler2].concat(args2));
1869
- }
1870
- };
1871
- return runHooksRecursive.apply(void 0, [obj, hookName, handler].concat(args));
1872
- } else {
1873
- return handler.call.apply(handler, [obj, obj].concat(args));
1874
- }
1875
- }
1876
1820
  function showErrorMsg(pluginName, msg) {
1877
1821
  XG_DEBUG.logError("[".concat(pluginName, "] event or callback cant be undefined or null when call ").concat(msg));
1878
1822
  }
@@ -2112,18 +2056,6 @@
2112
2056
  }
2113
2057
  }
2114
2058
  }
2115
- }, {
2116
- key: "defineMethod",
2117
- value: function defineMethod(Obj, map) {
2118
- for (var key in map) {
2119
- if (Object.prototype.hasOwnProperty.call(map, key) && typeof map[key] === "function") {
2120
- Object.defineProperty(Obj, key, {
2121
- configurable: true,
2122
- value: map[key]
2123
- });
2124
- }
2125
- }
2126
- }
2127
2059
  }, {
2128
2060
  key: "defaultConfig",
2129
2061
  get: function get() {
@@ -2746,7 +2678,7 @@
2746
2678
  arr2[i] = arr[i];
2747
2679
  return arr2;
2748
2680
  }
2749
- function _createForOfIteratorHelper$1(o, allowArrayLike) {
2681
+ function _createForOfIteratorHelper(o, allowArrayLike) {
2750
2682
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
2751
2683
  if (!it) {
2752
2684
  if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") {
@@ -2934,21 +2866,6 @@
2934
2866
  length: Buffer2.totalLength && Buffer2.totalLength(buffers)
2935
2867
  };
2936
2868
  }
2937
- }, {
2938
- key: "isBuffered",
2939
- value: function isBuffered(media, pos) {
2940
- if (media) {
2941
- var buffered = Buffer2.get(media);
2942
- if (buffered !== null && buffered !== void 0 && buffered.length) {
2943
- for (var i = 0; i < buffered.length; i++) {
2944
- if (pos >= buffered.start(i) && pos <= buffered.end(i)) {
2945
- return true;
2946
- }
2947
- }
2948
- }
2949
- }
2950
- return false;
2951
- }
2952
2869
  }]);
2953
2870
  return Buffer2;
2954
2871
  }();
@@ -3101,7 +3018,7 @@
3101
3018
  this.logCache.apply(this, [LogCacheLevel.DEBUG].concat(args));
3102
3019
  if (Logger2.disabled)
3103
3020
  return;
3104
- (_console = console).debug.apply(_console, ["[".concat(nowTime$1(), "]"), this._prefix].concat(args));
3021
+ (_console = console).debug.apply(_console, [this._prefix, nowTime$1()].concat(args));
3105
3022
  }
3106
3023
  }, {
3107
3024
  key: "log",
@@ -3113,7 +3030,7 @@
3113
3030
  this.logCache.apply(this, [LogCacheLevel.LOG].concat(args));
3114
3031
  if (Logger2.disabled)
3115
3032
  return;
3116
- (_console2 = console).log.apply(_console2, ["[".concat(nowTime$1(), "]"), this._prefix].concat(args));
3033
+ (_console2 = console).log.apply(_console2, [this._prefix, nowTime$1()].concat(args));
3117
3034
  }
3118
3035
  }, {
3119
3036
  key: "warn",
@@ -3125,7 +3042,7 @@
3125
3042
  this.logCache.apply(this, [LogCacheLevel.WARN].concat(args));
3126
3043
  if (Logger2.disabled)
3127
3044
  return;
3128
- (_console3 = console).warn.apply(_console3, ["[".concat(nowTime$1(), "]"), this._prefix].concat(args));
3045
+ (_console3 = console).warn.apply(_console3, [this._prefix, nowTime$1()].concat(args));
3129
3046
  }
3130
3047
  }, {
3131
3048
  key: "error",
@@ -3137,7 +3054,7 @@
3137
3054
  this.logCache.apply(this, [LogCacheLevel.ERROR].concat(args));
3138
3055
  if (Logger2.disabled)
3139
3056
  return;
3140
- (_console4 = console).error.apply(_console4, ["[".concat(nowTime$1(), "]"), this._prefix].concat(args));
3057
+ (_console4 = console).error.apply(_console4, [this._prefix, nowTime$1()].concat(args));
3141
3058
  }
3142
3059
  }, {
3143
3060
  key: "logCache",
@@ -3152,7 +3069,7 @@
3152
3069
  var finLogText = logText.map(function(item) {
3153
3070
  return logable(item);
3154
3071
  });
3155
- text = "[".concat(nowTime$1(), "]") + this._prefix + JSON.stringify(finLogText);
3072
+ text = this._prefix + nowTime$1() + JSON.stringify(finLogText);
3156
3073
  } catch (e) {
3157
3074
  return;
3158
3075
  }
@@ -4068,8 +3985,8 @@
4068
3985
  response
4069
3986
  };
4070
3987
  }
4071
- function calculateSpeed(byteLen, milliSecond) {
4072
- return Math.round(byteLen * 8 * 1e3 / milliSecond / 1024);
3988
+ function calculateSpeed(byteLen, millisec) {
3989
+ return Math.round(byteLen * 8 * 1e3 / millisec / 1024);
4073
3990
  }
4074
3991
  var EVENT = {
4075
3992
  ERROR: "error",
@@ -4081,7 +3998,6 @@
4081
3998
  SOURCEBUFFER_CREATED: "core.sourcebuffercreated",
4082
3999
  MEDIASOURCE_OPENED: "core.mediasourceopened",
4083
4000
  ANALYZE_DURATION_EXCEEDED: "core.analyzedurationexceeded",
4084
- APPEND_BUFFER: "core.appendbuffer",
4085
4001
  REMOVE_BUFFER: "core.removebuffer",
4086
4002
  BUFFEREOS: "core.buffereos",
4087
4003
  KEYFRAME: "core.keyframe",
@@ -4854,7 +4770,7 @@
4854
4770
  value: function _getHeaders(xhr) {
4855
4771
  var headerLines = xhr.getAllResponseHeaders().trim().split("\r\n");
4856
4772
  var headers = {};
4857
- var _iterator = _createForOfIteratorHelper$1(headerLines), _step;
4773
+ var _iterator = _createForOfIteratorHelper(headerLines), _step;
4858
4774
  try {
4859
4775
  for (_iterator.s(); !(_step = _iterator.n()).done; ) {
4860
4776
  var header = _step.value;
@@ -4876,7 +4792,7 @@
4876
4792
  }]);
4877
4793
  return XhrLoader2;
4878
4794
  }(EventEmitter);
4879
- var _excluded$2 = ["retry", "retryDelay", "onRetryError", "transformError"];
4795
+ var _excluded$1 = ["retry", "retryDelay", "onRetryError", "transformError"];
4880
4796
  var Task = /* @__PURE__ */ function() {
4881
4797
  function Task2(type, config) {
4882
4798
  _classCallCheck$1(this, Task2);
@@ -4896,7 +4812,7 @@
4896
4812
  key: "exec",
4897
4813
  value: function exec() {
4898
4814
  var _this = this;
4899
- 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);
4815
+ 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);
4900
4816
  var request = /* @__PURE__ */ function() {
4901
4817
  var _ref = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee() {
4902
4818
  var response, error, isRetry;
@@ -5692,60 +5608,6 @@
5692
5608
  function _nonIterableRest() {
5693
5609
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5694
5610
  }
5695
- function _createForOfIteratorHelper(o, allowArrayLike) {
5696
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
5697
- if (!it) {
5698
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
5699
- if (it)
5700
- o = it;
5701
- var i = 0;
5702
- var F = function() {
5703
- };
5704
- return {
5705
- s: F,
5706
- n: function() {
5707
- if (i >= o.length)
5708
- return {
5709
- done: true
5710
- };
5711
- return {
5712
- done: false,
5713
- value: o[i++]
5714
- };
5715
- },
5716
- e: function(e) {
5717
- throw e;
5718
- },
5719
- f: F
5720
- };
5721
- }
5722
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5723
- }
5724
- var normalCompletion = true, didErr = false, err;
5725
- return {
5726
- s: function() {
5727
- it = it.call(o);
5728
- },
5729
- n: function() {
5730
- var step = it.next();
5731
- normalCompletion = step.done;
5732
- return step;
5733
- },
5734
- e: function(e) {
5735
- didErr = true;
5736
- err = e;
5737
- },
5738
- f: function() {
5739
- try {
5740
- if (!normalCompletion && it.return != null)
5741
- it.return();
5742
- } finally {
5743
- if (didErr)
5744
- throw err;
5745
- }
5746
- }
5747
- };
5748
- }
5749
5611
  function _toPrimitive(input, hint) {
5750
5612
  if (typeof input !== "object" || input === null)
5751
5613
  return input;
@@ -5768,15 +5630,13 @@
5768
5630
  METADATA: "metadata"
5769
5631
  };
5770
5632
  var VideoCodecType = {
5771
- AV1: "av1",
5772
5633
  AVC: "avc",
5773
5634
  HEVC: "hevc"
5774
5635
  };
5775
5636
  var AudioCodecType = {
5776
5637
  AAC: "aac",
5777
5638
  G711PCMA: "g7110a",
5778
- G711PCMU: "g7110m",
5779
- OPUS: "opus"
5639
+ G711PCMU: "g7110m"
5780
5640
  };
5781
5641
  var WarningType = {
5782
5642
  LARGE_AV_SHIFT: "LARGE_AV_SHIFT",
@@ -5816,7 +5676,6 @@
5816
5676
  _defineProperty(this, "isVideoEncryption", false);
5817
5677
  _defineProperty(this, "isAudioEncryption", false);
5818
5678
  _defineProperty(this, "isVideo", true);
5819
- _defineProperty(this, "lastKeyFrameDts", 0);
5820
5679
  _defineProperty(this, "kid", null);
5821
5680
  _defineProperty(this, "pssh", null);
5822
5681
  _defineProperty(this, "ext", void 0);
@@ -5859,9 +5718,6 @@
5859
5718
  }, {
5860
5719
  key: "exist",
5861
5720
  value: function exist() {
5862
- if (/av01/.test(this.codec)) {
5863
- return true;
5864
- }
5865
5721
  return !!(this.pps.length && this.sps.length && this.codec);
5866
5722
  }
5867
5723
  }, {
@@ -5925,7 +5781,7 @@
5925
5781
  }, {
5926
5782
  key: "exist",
5927
5783
  value: function exist() {
5928
- return !!(this.sampleRate && this.channelCount && this.codec && (this.codecType === AudioCodecType.AAC || this.codecType === AudioCodecType.G711PCMA || this.codecType === AudioCodecType.G711PCMU || this.codecType === AudioCodecType.OPUS));
5784
+ return !!(this.sampleRate && this.channelCount && this.codec && this.codecType === AudioCodecType.AAC);
5929
5785
  }
5930
5786
  }, {
5931
5787
  key: "hasSample",
@@ -6130,7 +5986,7 @@
6130
5986
  continue;
6131
5987
  }
6132
5988
  frameLength = (data[i + 3] & 3) << 11 | data[i + 4] << 3 | (data[i + 5] & 224) >> 5;
6133
- if (!frameLength || len - i < frameLength)
5989
+ if (len - i < frameLength)
6134
5990
  break;
6135
5991
  protectionSkipBytes = (~data[i + 1] & 1) * 2;
6136
5992
  frames.push({
@@ -6324,15 +6180,6 @@
6324
6180
  return parseInt(item, 16);
6325
6181
  });
6326
6182
  }
6327
- function combineToFloat(integer, decimal) {
6328
- return Number(integer + "." + decimal);
6329
- }
6330
- function toDegree(matrix) {
6331
- if (matrix.length < 5)
6332
- return 0;
6333
- var scaled0 = Math.hypot(matrix[0], matrix[3]), scaled1 = Math.hypot(matrix[1], matrix[4]);
6334
- return 0 === scaled0 || 0 === scaled1 ? 0 : 180 * Math.atan2(matrix[1] / scaled1, matrix[0] / scaled0) / Math.PI;
6335
- }
6336
6183
  var NALu = /* @__PURE__ */ function() {
6337
6184
  function NALu2() {
6338
6185
  _classCallCheck(this, NALu2);
@@ -6995,16 +6842,13 @@
6995
6842
  var AUDIO_EXCETION_LOG_EMIT_DURATION = 5 * 9e4;
6996
6843
  var MAX_VIDEO_FRAME_DURATION = 9e4;
6997
6844
  var MAX_DTS_DELTA_WITH_NEXT_CHUNK = 9e4 / 2;
6998
- var LARGE_AV_FIRST_FRAME_FORCE_FIX_THRESHOLD = 9e4 * 5;
6999
6845
  var TsFixer = /* @__PURE__ */ function() {
7000
- function TsFixer2(videoTrack, audioTrack, metadataTrack, fixerConfig) {
6846
+ function TsFixer2(videoTrack, audioTrack, metadataTrack) {
7001
6847
  _classCallCheck(this, TsFixer2);
7002
6848
  this.videoTrack = videoTrack;
7003
6849
  this.audioTrack = audioTrack;
7004
6850
  this.metadataTrack = metadataTrack;
7005
6851
  this._baseDts = -1;
7006
- this._baseVideoDts = -1;
7007
- this._baseAudioDts = -1;
7008
6852
  this._baseDtsInited = false;
7009
6853
  this._audioNextPts = void 0;
7010
6854
  this._videoNextDts = void 0;
@@ -7013,8 +6857,6 @@
7013
6857
  this._lastAudioExceptionGapDot = 0;
7014
6858
  this._lastAudioExceptionOverlapDot = 0;
7015
6859
  this._lastAudioExceptionLargeGapDot = 0;
7016
- this._needForceFixLargeGap = fixerConfig === null || fixerConfig === void 0 ? void 0 : fixerConfig.forceFixLargeGap;
7017
- this._largeGapThreshold = (fixerConfig === null || fixerConfig === void 0 ? void 0 : fixerConfig.largeGapThreshold) || LARGE_AV_FIRST_FRAME_FORCE_FIX_THRESHOLD;
7018
6860
  }
7019
6861
  _createClass(TsFixer2, [{
7020
6862
  key: "fix",
@@ -7042,16 +6884,10 @@
7042
6884
  if (discontinuity) {
7043
6885
  this._calculateBaseDts(this.audioTrack, this.videoTrack);
7044
6886
  this._baseDts -= startTime;
7045
- this._baseAudioDts -= startTime;
7046
- this._baseVideoDts -= startTime;
7047
6887
  }
7048
6888
  if (!contiguous) {
7049
6889
  this._videoNextDts = vaDelta > 0 ? startTime + vaDelta : startTime;
7050
6890
  this._audioNextPts = vaDelta > 0 ? startTime : startTime - vaDelta;
7051
- if (this._needForceFixLargeGap) {
7052
- this._videoNextDts = 0;
7053
- this._audioNextPts = 0;
7054
- }
7055
6891
  var vDeltaToNextDts = firstVideoSample ? firstVideoSample.dts - this._baseDts - this._videoNextDts : 0;
7056
6892
  var aDeltaToNextDts = firstAudioSample ? firstAudioSample.pts - this._baseDts - this._audioNextPts : 0;
7057
6893
  if (Math.abs(vDeltaToNextDts || aDeltaToNextDts) > MAX_VIDEO_FRAME_DURATION) {
@@ -7084,8 +6920,8 @@
7084
6920
  if (!samples.length)
7085
6921
  return;
7086
6922
  samples.forEach(function(x) {
7087
- x.dts -= _this2._needForceFixLargeGap ? _this2._baseVideoDts : _this2._baseDts;
7088
- x.pts -= _this2._needForceFixLargeGap ? _this2._baseVideoDts : _this2._baseDts;
6923
+ x.dts -= _this2._baseDts;
6924
+ x.pts -= _this2._baseDts;
7089
6925
  });
7090
6926
  if (this._videoNextDts === void 0) {
7091
6927
  var samp0 = samples[0];
@@ -7178,7 +7014,7 @@
7178
7014
  if (!samples.length)
7179
7015
  return;
7180
7016
  samples.forEach(function(x) {
7181
- x.pts -= _this3._needForceFixLargeGap ? _this3._baseAudioDts : _this3._baseDts;
7017
+ x.pts -= _this3._baseDts;
7182
7018
  x.dts = x.pts;
7183
7019
  });
7184
7020
  this._doFixAudioInternal(audioTrack, samples, 9e4);
@@ -7195,15 +7031,12 @@
7195
7031
  var videoBaseDts = Infinity;
7196
7032
  if (audioSamps.length) {
7197
7033
  audioTrack.baseDts = audioBasePts = audioSamps[0].pts;
7198
- this._baseAudioDts = audioBasePts;
7199
7034
  }
7200
7035
  if (videoSamps.length) {
7201
7036
  videoTrack.baseDts = videoBaseDts = videoSamps[0].dts;
7202
- this._baseVideoDts = videoBaseDts;
7203
7037
  }
7204
7038
  this._baseDts = Math.min(audioBasePts, videoBaseDts);
7205
7039
  var delta = videoBaseDts - audioBasePts;
7206
- var largeGap = false;
7207
7040
  if (Number.isFinite(delta) && Math.abs(delta) > LARGE_AV_FIRST_FRAME_GAP) {
7208
7041
  videoTrack.warnings.push({
7209
7042
  type: WarningType.LARGE_AV_SHIFT,
@@ -7213,16 +7046,6 @@
7213
7046
  delta
7214
7047
  });
7215
7048
  }
7216
- if (Number.isFinite(delta) && Math.abs(delta) > this._largeGapThreshold * MAX_SILENT_FRAME_DURATION) {
7217
- largeGap = true;
7218
- }
7219
- if (!this._baseDtsInited) {
7220
- if (largeGap && this._needForceFixLargeGap) {
7221
- this._needForceFixLargeGap = true;
7222
- } else {
7223
- this._needForceFixLargeGap = false;
7224
- }
7225
- }
7226
7049
  this._baseDtsInited = true;
7227
7050
  return true;
7228
7051
  }
@@ -7316,7 +7139,6 @@
7316
7139
  var logger$4 = new Logger$1("TsDemuxer");
7317
7140
  var TsDemuxer = /* @__PURE__ */ function() {
7318
7141
  function TsDemuxer2(videoTrack, audioTrack, metadataTrack) {
7319
- var fixerConfig = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
7320
7142
  _classCallCheck(this, TsDemuxer2);
7321
7143
  _defineProperty(this, "_pmtId", -1);
7322
7144
  _defineProperty(this, "_remainingPacketData", null);
@@ -7326,7 +7148,7 @@
7326
7148
  this.videoTrack = videoTrack || new VideoTrack();
7327
7149
  this.audioTrack = audioTrack || new AudioTrack();
7328
7150
  this.metadataTrack = metadataTrack || new MetadataTrack();
7329
- this._fixer = new TsFixer(this.videoTrack, this.audioTrack, this.metadataTrack, fixerConfig);
7151
+ this._fixer = new TsFixer(this.videoTrack, this.audioTrack, this.metadataTrack);
7330
7152
  }
7331
7153
  _createClass(TsDemuxer2, [{
7332
7154
  key: "demux",
@@ -7673,207 +7495,6 @@
7673
7495
  }]);
7674
7496
  return TsDemuxer2;
7675
7497
  }();
7676
- var ByteReader = /* @__PURE__ */ function() {
7677
- function ByteReader2(buf, offset, len) {
7678
- _classCallCheck(this, ByteReader2);
7679
- this.dv = new DataView(buf);
7680
- this.start = this.offset = offset || this.dv.byteOffset;
7681
- this.end = len ? this.start + len : this.start + this.dv.byteLength;
7682
- }
7683
- _createClass(ByteReader2, [{
7684
- key: "buffer",
7685
- get: function get() {
7686
- return this.dv.buffer;
7687
- }
7688
- }, {
7689
- key: "unreadLength",
7690
- get: function get() {
7691
- return Math.max(this.end - this.offset, 0);
7692
- }
7693
- }, {
7694
- key: "size",
7695
- get: function get() {
7696
- return this.end - this.start;
7697
- }
7698
- }, {
7699
- key: "readFloat",
7700
- value: function readFloat(byteNum) {
7701
- var val = 0;
7702
- switch (byteNum) {
7703
- case 4:
7704
- val = this.dv.getFloat32(this.offset);
7705
- break;
7706
- case 8:
7707
- val = this.dv.getFloat64(this.offset);
7708
- break;
7709
- default:
7710
- throw new Error("read ".concat(byteNum, "-byte float is not supported"));
7711
- }
7712
- this.offset += byteNum;
7713
- return val;
7714
- }
7715
- }, {
7716
- key: "back",
7717
- value: function back(byteNum) {
7718
- this.offset -= byteNum;
7719
- }
7720
- }, {
7721
- key: "skip",
7722
- value: function skip(byteNum) {
7723
- this.offset += byteNum;
7724
- }
7725
- }, {
7726
- key: "readInt",
7727
- value: function readInt(byteNum) {
7728
- var offset = this.offset;
7729
- this.offset += byteNum;
7730
- switch (byteNum) {
7731
- case 1:
7732
- return this.dv.getInt8(offset);
7733
- case 2:
7734
- return this.dv.getInt16(offset);
7735
- case 4:
7736
- return this.dv.getInt32(offset);
7737
- default:
7738
- throw new Error("read ".concat(byteNum, "-byte integers is not supported"));
7739
- }
7740
- }
7741
- }, {
7742
- key: "read",
7743
- value: function read(byteNum) {
7744
- var offset = this.offset;
7745
- this.offset += byteNum;
7746
- switch (byteNum) {
7747
- case 1:
7748
- return this.dv.getUint8(offset);
7749
- case 2:
7750
- return this.dv.getUint16(offset);
7751
- case 3:
7752
- return (this.dv.getUint16(offset) << 8) + this.dv.getUint8(offset + 2);
7753
- case 4:
7754
- return this.dv.getUint32(offset);
7755
- default:
7756
- this.back(byteNum - 4);
7757
- return this.read(byteNum - 4) + this.dv.getUint32(offset) * Math.pow(256, byteNum - 4);
7758
- }
7759
- }
7760
- }, {
7761
- key: "write",
7762
- value: function write(byteNum, val) {
7763
- var offset = this.offset;
7764
- this.offset += byteNum;
7765
- switch (byteNum) {
7766
- case 1:
7767
- return this.dv.setUint8(offset, val);
7768
- case 2:
7769
- return this.dv.setUint16(offset, val);
7770
- case 3:
7771
- return this.dv.setUint8(offset, val >>> 16), this.dv.setUint16(offset + 1, 65535 & val);
7772
- case 4:
7773
- return this.dv.setUint32(offset, val);
7774
- default:
7775
- throw new Error("write ".concat(byteNum, "-byte integers is not supported"));
7776
- }
7777
- }
7778
- }, {
7779
- key: "readToBuffer",
7780
- value: function readToBuffer(len) {
7781
- var buffer;
7782
- if (this.offset || len) {
7783
- buffer = this.dv.buffer.slice(this.offset, len ? this.offset + len : this.end);
7784
- } else {
7785
- buffer = this.dv.buffer;
7786
- }
7787
- this.offset += buffer.byteLength;
7788
- return buffer;
7789
- }
7790
- }, {
7791
- key: "readToUint8",
7792
- value: function readToUint8(len) {
7793
- var uint8 = new Uint8Array(this.dv.buffer, this.offset, len || this.unreadLength);
7794
- this.offset += uint8.byteLength;
7795
- return uint8;
7796
- }
7797
- }, {
7798
- key: "readString",
7799
- value: function readString(len) {
7800
- var i = 0, str = "";
7801
- for (; i < len; i++) {
7802
- str += String.fromCharCode(this.dv.getUint8(this.offset));
7803
- this.offset++;
7804
- }
7805
- return str;
7806
- }
7807
- }], [{
7808
- key: "fromUint8",
7809
- value: function fromUint8(uint8) {
7810
- return new ByteReader2(uint8.buffer, uint8.byteOffset, uint8.byteLength);
7811
- }
7812
- }, {
7813
- key: "concatUint8s",
7814
- value: function concatUint8s(args) {
7815
- var uint8 = new Uint8Array(args.reduce(function(ret, v) {
7816
- return ret + v.byteLength;
7817
- }, 0));
7818
- var offset = 0;
7819
- args.forEach(function(v) {
7820
- uint8.set(v, offset);
7821
- offset += v.byteLength;
7822
- });
7823
- return uint8;
7824
- }
7825
- }, {
7826
- key: "concatUint8",
7827
- value: function concatUint8() {
7828
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
7829
- args[_key] = arguments[_key];
7830
- }
7831
- return this.concatUint8s(args);
7832
- }
7833
- }]);
7834
- return ByteReader2;
7835
- }();
7836
- var BitReader = /* @__PURE__ */ function() {
7837
- function BitReader2(val, size) {
7838
- _classCallCheck(this, BitReader2);
7839
- this.offset = 0;
7840
- this.val = val;
7841
- this.size = size;
7842
- }
7843
- _createClass(BitReader2, [{
7844
- key: "skip",
7845
- value: function skip(len) {
7846
- this.offset += len;
7847
- }
7848
- }, {
7849
- key: "read",
7850
- value: function read(len) {
7851
- var unreadLength = this.size - this.offset - len;
7852
- if (unreadLength >= 0) {
7853
- var bits = 0, i = 0;
7854
- this.offset += len;
7855
- if (this.size > 31) {
7856
- for (; i < len; i++) {
7857
- bits += Math.pow(2, i);
7858
- }
7859
- return this.val / Math.pow(2, unreadLength) & bits;
7860
- } else {
7861
- for (; i < len; i++) {
7862
- bits += 1 << i;
7863
- }
7864
- return this.val >>> unreadLength & bits;
7865
- }
7866
- }
7867
- throw new Error("the number of the read operation exceeds the total length limit of bits");
7868
- }
7869
- }], [{
7870
- key: "fromByte",
7871
- value: function fromByte(byte, len) {
7872
- return new BitReader2(byte.read(len), len << 3);
7873
- }
7874
- }]);
7875
- return BitReader2;
7876
- }();
7877
7498
  var MP4Parser = /* @__PURE__ */ function() {
7878
7499
  function MP4Parser2() {
7879
7500
  _classCallCheck(this, MP4Parser2);
@@ -8031,36 +7652,18 @@
8031
7652
  key: "tkhd",
8032
7653
  value: function tkhd(box) {
8033
7654
  return parseBox(box, true, function(ret, data) {
8034
- var byte = ByteReader.fromUint8(data);
7655
+ var start = 0;
8035
7656
  if (ret.version === 1) {
8036
- byte.read(8);
8037
- byte.read(8);
8038
- ret.trackId = byte.read(4);
8039
- byte.read(4);
8040
- ret.duration = byte.read(8);
7657
+ ret.trackId = readBig32(data, 16);
7658
+ ret.duration = readBig64(data, 24);
7659
+ start += 32;
8041
7660
  } else {
8042
- byte.read(4);
8043
- byte.read(4);
8044
- ret.trackId = byte.read(4);
8045
- byte.read(4);
8046
- ret.duration = byte.read(4);
7661
+ ret.trackId = readBig32(data, 8);
7662
+ ret.duration = readBig32(data, 16);
7663
+ start += 20;
8047
7664
  }
8048
- byte.skip(16);
8049
- ret.matrix = [];
8050
- for (var i = 0; i < 36; i++) {
8051
- ret.matrix.push(byte.read(1));
8052
- }
8053
- byte.back(36);
8054
- var caculatedMatrix = [];
8055
- for (var _i = 0, int32; _i < 3; _i++) {
8056
- caculatedMatrix.push(combineToFloat(byte.readInt(2), byte.readInt(2)));
8057
- caculatedMatrix.push(combineToFloat(byte.readInt(2), byte.readInt(2)));
8058
- int32 = byte.readInt(4);
8059
- caculatedMatrix.push(combineToFloat(int32 >> 30, int32 & 1073741823));
8060
- }
8061
- ret.rotation = toDegree(caculatedMatrix);
8062
- ret.width = byte.read(4);
8063
- ret.height = byte.read(4);
7665
+ ret.width = readBig32(data, start + 52);
7666
+ ret.height = readBig32(data, start + 56);
8064
7667
  });
8065
7668
  }
8066
7669
  }, {
@@ -8190,7 +7793,7 @@
8190
7793
  if (ret.version > 0) {
8191
7794
  var numKeyIds = readBig32(data, start);
8192
7795
  start += 4;
8193
- for (var _i2 = 0; _i2 < ("" + numKeyIds).length; _i2++) {
7796
+ for (var _i = 0; _i < ("" + numKeyIds).length; _i++) {
8194
7797
  for (var j = 0; j < 16; j++) {
8195
7798
  var keyId = data[start];
8196
7799
  start += 1;
@@ -8213,8 +7816,6 @@
8213
7816
  ret.entryCount = readBig32(data);
8214
7817
  ret.entries = MP4Parser2.findBox(data.subarray(4), [], start + 4).map(function(b) {
8215
7818
  switch (b.type) {
8216
- case "av01":
8217
- return MP4Parser2.av01(b);
8218
7819
  case "avc1":
8219
7820
  case "avc2":
8220
7821
  case "avc3":
@@ -8294,69 +7895,6 @@
8294
7895
  }
8295
7896
  });
8296
7897
  }
8297
- }, {
8298
- key: "colr",
8299
- value: function colr(box) {
8300
- return parseBox(box, false, function(ret, data) {
8301
- var byte = ByteReader.fromUint8(data);
8302
- ret.data = box.data;
8303
- ret.colorType = byte.readString(4);
8304
- if (ret.colorType === "nclx") {
8305
- ret.colorPrimaries = byte.read(2);
8306
- ret.transferCharacteristics = byte.read(2);
8307
- ret.matrixCoefficients = byte.read(2);
8308
- ret.fullRangeFlag = byte.read(1) >> 7;
8309
- } else if (ret.colorType === "rICC" || ret.colorType === "prof") {
8310
- ret.iccProfile = data.readToUint8();
8311
- }
8312
- });
8313
- }
8314
- }, {
8315
- key: "av01",
8316
- value: function av01(box) {
8317
- return parseBox(box, false, function(ret, data, start) {
8318
- var bodyStart = parseVisualSampleEntry(ret, data);
8319
- var bodyData = data.subarray(bodyStart);
8320
- start += bodyStart;
8321
- ret.av1C = MP4Parser2.av1C(MP4Parser2.findBox(bodyData, ["av1C"], start)[0]);
8322
- ret.colr = MP4Parser2.colr(MP4Parser2.findBox(bodyData, ["colr"], start)[0]);
8323
- });
8324
- }
8325
- }, {
8326
- key: "av1C",
8327
- value: function av1C(box) {
8328
- return parseBox(box, false, function(ret, data) {
8329
- ret.data = box.data;
8330
- var byte = ByteReader.fromUint8(data);
8331
- var bit = BitReader.fromByte(byte, 4);
8332
- ret.marker = bit.read(1);
8333
- ret.version = bit.read(7);
8334
- ret.seqProfile = bit.read(3);
8335
- ret.seqLevelIdx0 = bit.read(5);
8336
- ret.seqTier0 = bit.read(1);
8337
- ret.highBitdepth = bit.read(1);
8338
- ret.twelveBit = bit.read(1);
8339
- ret.monochrome = bit.read(1);
8340
- ret.chromaSubsamplingX = bit.read(1);
8341
- ret.chromaSubsamplingY = bit.read(1);
8342
- ret.chromaSamplePosition = bit.read(2);
8343
- ret.reserved = bit.read(3);
8344
- ret.initialPresentationDelayPresent = bit.read(1);
8345
- if (ret.initialPresentationDelayPresent) {
8346
- ret.initialPresentationDelayMinusOne = bit.read(4);
8347
- } else {
8348
- ret.initialPresentationDelayMinusOne = 0;
8349
- }
8350
- ret.configOBUs = byte.readToUint8();
8351
- var bitdepth;
8352
- if (ret.seqLevelIdx0 === 2 && ret.highBitdepth === 1) {
8353
- bitdepth = ret.twelveBit === 1 ? "12" : "10";
8354
- } else if (ret.seqProfile <= 2) {
8355
- bitdepth = ret.highBitdepth === 1 ? "10" : "08";
8356
- }
8357
- ret.codec = ["av01", ret.seqProfile, (ret.seqLevelIdx0 < 10 ? "0" + ret.seqLevelIdx0 : ret.seqLevelIdx0) + (ret.seqTier0 ? "H" : "M"), bitdepth].join(".");
8358
- });
8359
- }
8360
7898
  }, {
8361
7899
  key: "avc1",
8362
7900
  value: function avc1(box) {
@@ -8391,7 +7929,7 @@
8391
7929
  ret.ppsLength = data[start];
8392
7930
  start += 1;
8393
7931
  ret.pps = [];
8394
- for (var _i3 = 0; _i3 < ret.ppsLength; _i3++) {
7932
+ for (var _i2 = 0; _i2 < ret.ppsLength; _i2++) {
8395
7933
  var _size = readBig16(data, start);
8396
7934
  start += 2;
8397
7935
  ret.pps.push(data.subarray(start, start += _size));
@@ -8560,7 +8098,7 @@
8560
8098
  start += 8;
8561
8099
  }
8562
8100
  } else {
8563
- for (var _i4 = 0; _i4 < entryCount; _i4++) {
8101
+ for (var _i3 = 0; _i3 < entryCount; _i3++) {
8564
8102
  entries.push({
8565
8103
  count: readBig32(data, start),
8566
8104
  offset: -(~readBig32(data, start + 4) + 1)
@@ -8782,20 +8320,13 @@
8782
8320
  v.mvhdTimecale = moov.mvhd.timescale;
8783
8321
  v.timescale = v.formatTimescale = vTrack.mdia.mdhd.timescale;
8784
8322
  v.duration = vTrack.mdia.mdhd.duration || v.mvhdDurtion / v.mvhdTimecale * v.timescale;
8785
- v.rotation = vTrack.tkhd.rotation;
8786
- v.matrix = vTrack.tkhd.matrix;
8787
8323
  var e1 = vTrack.mdia.minf.stbl.stsd.entries[0];
8788
8324
  v.width = e1.width;
8789
8325
  v.height = e1.height;
8790
8326
  if (e1.pasp) {
8791
8327
  v.sarRatio = [e1.pasp.hSpacing, e1.pasp.vSpacing];
8792
8328
  }
8793
- if (e1.av1C) {
8794
- v.codecType = VideoCodecType.AV1;
8795
- v.codec = e1.av1C.codec;
8796
- v.av1C = e1.av1C.data;
8797
- v.colr = e1.colr.data;
8798
- } else if (e1.hvcC) {
8329
+ if (e1.hvcC) {
8799
8330
  v.codecType = VideoCodecType.HEVC;
8800
8331
  v.codec = e1.hvcC.codec;
8801
8332
  v.vps = e1.hvcC.vps;
@@ -9114,9 +8645,8 @@
9114
8645
  function parseBox(box, isFullBox, parse2) {
9115
8646
  if (!box)
9116
8647
  return;
9117
- if (box.size !== box.data.length) {
8648
+ if (box.size !== box.data.length)
9118
8649
  throw new Error("box ".concat(box.type, " size !== data.length"));
9119
- }
9120
8650
  var ret = {
9121
8651
  start: box.start,
9122
8652
  size: box.size,
@@ -9155,167 +8685,11 @@
9155
8685
  var FMP4Demuxer = /* @__PURE__ */ function() {
9156
8686
  function FMP4Demuxer2(videoTrack, audioTrack, metadataTrack) {
9157
8687
  _classCallCheck(this, FMP4Demuxer2);
9158
- _defineProperty(this, "__loadedMoofWraps", []);
9159
- _defineProperty(this, "__lastRemainData", null);
9160
- _defineProperty(this, "__lastRemainDataStart", 0);
9161
- _defineProperty(this, "__nextMoofStart", -1);
9162
8688
  this.videoTrack = videoTrack || new VideoTrack();
9163
8689
  this.audioTrack = audioTrack || new AudioTrack();
9164
8690
  this.metadataTrack = metadataTrack || new MetadataTrack();
9165
8691
  }
9166
8692
  _createClass(FMP4Demuxer2, [{
9167
- key: "demuxPart",
9168
- value: function demuxPart(partData, partDataStart, moov) {
9169
- var _this = this;
9170
- var videoTrack = this.videoTrack, audioTrack = this.audioTrack;
9171
- var videoExist = videoTrack.exist();
9172
- var audioExist = audioTrack.exist();
9173
- var isAV01 = /av01/.test(videoTrack.codec);
9174
- videoTrack.samples = [];
9175
- audioTrack.samples = [];
9176
- var data = partData;
9177
- var dataStart = partDataStart;
9178
- if (this.__lastRemainData) {
9179
- var lastRemainDataEnd = this.__lastRemainDataStart + this.__lastRemainData.byteLength;
9180
- var continuous = partDataStart <= lastRemainDataEnd && partDataStart > this.__lastRemainDataStart && partDataStart + partData.byteLength > lastRemainDataEnd;
9181
- if (continuous) {
9182
- var noDuplicateData = partData.subarray(this.__lastRemainData.byteLength + this.__lastRemainDataStart - partDataStart);
9183
- data = concatUint8Array(this.__lastRemainData, noDuplicateData);
9184
- dataStart = this.__lastRemainDataStart;
9185
- this.__lastRemainData = null;
9186
- } else {
9187
- this.__lastRemainData = null;
9188
- this.__lastRemainDataStart = 0;
9189
- this.__nextMoofStart = -1;
9190
- }
9191
- }
9192
- if (!moov) {
9193
- var moovBox = MP4Parser.findBox(data, ["moov"])[0];
9194
- if (!moovBox)
9195
- throw new Error("cannot found moov box");
9196
- moov = MP4Parser.moov(moovBox);
9197
- }
9198
- if (data) {
9199
- var dataEnd = dataStart + data.byteLength;
9200
- if (!videoExist && !audioExist) {
9201
- MP4Parser.moovToTrack(moov, videoTrack, audioTrack);
9202
- }
9203
- var moofBoxes = [];
9204
- if (this.__nextMoofStart < 0) {
9205
- MP4Parser.findBox(data, ["moof"], dataStart).forEach(function(v) {
9206
- return moofBoxes.push(v);
9207
- });
9208
- } else if (this.__nextMoofStart >= dataStart && this.__nextMoofStart <= dataEnd - 8) {
9209
- MP4Parser.findBox(data.subarray(this.__nextMoofStart - dataStart), ["moof"], this.__nextMoofStart).forEach(function(v) {
9210
- return moofBoxes.push(v);
9211
- });
9212
- }
9213
- moofBoxes.filter(function(moofBox) {
9214
- return moofBox.size <= moofBox.data.length;
9215
- }).forEach(function(moofBox) {
9216
- var moof = MP4Parser.moof(moofBox);
9217
- _this.__nextMoofStart = moof.start + Math.max.apply(Math, _toConsumableArray(moof.traf.map(function(v) {
9218
- return v.trun.samples.reduce(function(ret, w) {
9219
- return ret + w.size;
9220
- }, v.trun.dataOffset || 0);
9221
- })));
9222
- _this.__loadedMoofWraps.push({
9223
- start: moof.start,
9224
- nextMoofStart: _this.__nextMoofStart,
9225
- moof
9226
- });
9227
- _this.__loadedMoofWraps.sort(function(p, n) {
9228
- return p.start - n.start;
9229
- });
9230
- });
9231
- var _iterator = _createForOfIteratorHelper(this.__loadedMoofWraps), _step;
9232
- try {
9233
- var _loop = function _loop2() {
9234
- var moofWrap = _step.value;
9235
- if (moofWrap.start > dataEnd || moofWrap.nextMoofStart < dataStart) {
9236
- return "continue";
9237
- }
9238
- var moofStart = moofWrap.start;
9239
- var tracks = MP4Parser.moofToSamples(moofWrap.moof, videoTrack, audioTrack);
9240
- var videoBaseMediaDecodeTime = videoTrack.baseMediaDecodeTime;
9241
- var audioBaseMediaDecodeTime = audioTrack.baseMediaDecodeTime;
9242
- var nalSize;
9243
- Object.keys(tracks).forEach(function(k) {
9244
- if (videoTrack.id == k) {
9245
- tracks[k].some(function(x) {
9246
- var xStart = x.offset += moofStart;
9247
- if (xStart < dataStart) {
9248
- return;
9249
- }
9250
- if (xStart + x.size > dataEnd) {
9251
- return true;
9252
- }
9253
- var sample = new VideoSample((x.pts || x.dts) + videoBaseMediaDecodeTime, x.dts + videoBaseMediaDecodeTime);
9254
- sample.duration = x.duration;
9255
- sample.gopId = x.gopId;
9256
- if (x.keyframe)
9257
- sample.setToKeyframe();
9258
- var sampleData = data.subarray(xStart - dataStart, xStart - dataStart + x.size);
9259
- sample.data = sampleData;
9260
- if (!isAV01) {
9261
- var start = 0;
9262
- var len = sampleData.length - 1;
9263
- while (start < len) {
9264
- nalSize = readBig32(sampleData, start);
9265
- start += 4;
9266
- sample.units.push(sampleData.subarray(start, start + nalSize));
9267
- start += nalSize;
9268
- }
9269
- }
9270
- _this.__lastRemainDataStart = xStart + x.size;
9271
- videoTrack.samples.push(sample);
9272
- });
9273
- } else if (audioTrack.id == k) {
9274
- tracks[k].some(function(x) {
9275
- var xStart = x.offset + moofStart;
9276
- if (xStart < dataStart) {
9277
- return;
9278
- }
9279
- if (xStart + x.size > dataEnd) {
9280
- return true;
9281
- }
9282
- var sampleData = data.subarray(xStart - dataStart, xStart - dataStart + x.size);
9283
- audioTrack.samples.push(new AudioSample(x.dts + audioBaseMediaDecodeTime, sampleData, x.duration));
9284
- _this.__lastRemainDataStart = xStart + x.size;
9285
- });
9286
- }
9287
- });
9288
- };
9289
- for (_iterator.s(); !(_step = _iterator.n()).done; ) {
9290
- var _ret = _loop();
9291
- if (_ret === "continue")
9292
- continue;
9293
- }
9294
- } catch (err) {
9295
- _iterator.e(err);
9296
- } finally {
9297
- _iterator.f();
9298
- }
9299
- }
9300
- if (this.__lastRemainDataStart > dataStart && this.__lastRemainDataStart < data.byteLength + dataStart) {
9301
- this.__lastRemainData = data.subarray(this.__lastRemainDataStart - dataStart);
9302
- } else {
9303
- this.__lastRemainData = data;
9304
- this.__lastRemainDataStart = dataStart;
9305
- }
9306
- if (videoTrack.samples.length) {
9307
- videoTrack.baseMediaDecodeTime = videoTrack.samples[0].pts;
9308
- }
9309
- if (audioTrack.samples.length) {
9310
- audioTrack.baseMediaDecodeTime = audioTrack.samples[0].pts;
9311
- }
9312
- return {
9313
- videoTrack,
9314
- audioTrack,
9315
- metadataTrack: this.metadataTrack
9316
- };
9317
- }
9318
- }, {
9319
8693
  key: "demux",
9320
8694
  value: function demux(videoData, audioData) {
9321
8695
  var videoTrack = this.videoTrack, audioTrack = this.audioTrack;
@@ -9807,16 +9181,10 @@
9807
9181
  if (track.useEME && track.enca) {
9808
9182
  content = MP42.enca(track);
9809
9183
  } else {
9810
- if (track.codecType === AudioCodecType.OPUS) {
9811
- content = MP42.opus(track);
9812
- } else {
9813
- content = MP42.mp4a(track);
9814
- }
9184
+ content = MP42.mp4a(track);
9815
9185
  }
9816
9186
  } else if (track.useEME && track.encv) {
9817
9187
  content = MP42.encv(track);
9818
- } else if (track.av1C) {
9819
- content = MP42.av01(track);
9820
9188
  } else {
9821
9189
  content = MP42.avc1hev1(track);
9822
9190
  }
@@ -10030,96 +9398,12 @@
10030
9398
  return MP42.box(MP42.types.sinf, content, MP42.box(MP42.types.frma, frma), MP42.box(MP42.types.schm, schm), schi);
10031
9399
  }
10032
9400
  }, {
10033
- key: "av01",
10034
- value: function av01(track) {
10035
- return MP42.box(MP42.types.av01, new Uint8Array([
10036
- 0,
10037
- 0,
10038
- 0,
10039
- 0,
10040
- 0,
10041
- 0,
10042
- 0,
10043
- 1,
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
- 0,
10057
- 0,
10058
- 0,
10059
- 0,
10060
- track.width >> 8 & 255,
10061
- track.width & 255,
10062
- track.height >> 8 & 255,
10063
- track.height & 255,
10064
- 0,
10065
- 72,
10066
- 0,
10067
- 0,
10068
- 0,
10069
- 72,
10070
- 0,
10071
- 0,
10072
- 0,
10073
- 0,
10074
- 0,
10075
- 0,
10076
- 0,
10077
- 1,
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
- 0,
10108
- 0,
10109
- 0,
10110
- 0,
10111
- 24,
10112
- 17,
10113
- 17
10114
- ]), track.av1C, track.colr);
10115
- }
10116
- }, {
10117
- key: "avc1hev1",
10118
- value: function avc1hev1(track) {
10119
- var isHevc = track.codecType === VideoCodecType.HEVC;
10120
- var typ = isHevc ? MP42.types.hvc1 : MP42.types.avc1;
10121
- var config = isHevc ? MP42.hvcC(track) : MP42.avcC(track);
10122
- var boxes = [new Uint8Array([
9401
+ key: "avc1hev1",
9402
+ value: function avc1hev1(track) {
9403
+ var isHevc = track.codecType === VideoCodecType.HEVC;
9404
+ var typ = isHevc ? MP42.types.hvc1 : MP42.types.avc1;
9405
+ var config = isHevc ? MP42.hvcC(track) : MP42.avcC(track);
9406
+ var boxes = [new Uint8Array([
10123
9407
  0,
10124
9408
  0,
10125
9409
  0,
@@ -10483,53 +9767,6 @@
10483
9767
  )));
10484
9768
  return esds2;
10485
9769
  }
10486
- }, {
10487
- key: "opus",
10488
- value: function opus(track) {
10489
- var opusAudioDescription = new Uint8Array([
10490
- 0,
10491
- 0,
10492
- 0,
10493
- 0,
10494
- 0,
10495
- 0,
10496
- 0,
10497
- 1,
10498
- 0,
10499
- 0,
10500
- 0,
10501
- 0,
10502
- 0,
10503
- 0,
10504
- 0,
10505
- 0,
10506
- 0,
10507
- track.channelCount,
10508
- 0,
10509
- 16,
10510
- 0,
10511
- 0,
10512
- 0,
10513
- 0,
10514
- track.sampleRate >> 8 & 255,
10515
- track.sampleRate & 255,
10516
- 0,
10517
- 0
10518
- ]);
10519
- var opusSpecificConfig = track.config.length ? MP42.dOps(track) : [];
10520
- return MP42.box(MP42.types.Opus, opusAudioDescription, opusSpecificConfig);
10521
- }
10522
- }, {
10523
- key: "dOps",
10524
- value: function dOps(track) {
10525
- if (track.config) {
10526
- track.config[4] = track.sampleRate >>> 24 & 255;
10527
- track.config[5] = track.sampleRate >>> 16 & 255;
10528
- track.config[6] = track.sampleRate >>> 8 & 255;
10529
- track.config[7] = track.sampleRate & 255;
10530
- return MP42.box(MP42.types.dOps, track.config);
10531
- }
10532
- }
10533
9770
  }, {
10534
9771
  key: "mvex",
10535
9772
  value: function mvex(tracks) {
@@ -11132,7 +10369,7 @@
11132
10369
  }]);
11133
10370
  return MP42;
11134
10371
  }();
11135
- _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) {
10372
+ _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) {
11136
10373
  p[c] = [c.charCodeAt(0), c.charCodeAt(1), c.charCodeAt(2), c.charCodeAt(3)];
11137
10374
  return p;
11138
10375
  }, /* @__PURE__ */ Object.create(null)));
@@ -11467,46 +10704,30 @@
11467
10704
  };
11468
10705
  }
11469
10706
  var samples = track.samples;
11470
- var isAV01 = /av01/.test(track.codec);
11471
10707
  var mdatSize = 0;
11472
- if (isAV01) {
11473
- samples.forEach(function(s) {
11474
- mdatSize += s.data.byteLength;
11475
- });
11476
- } else {
11477
- samples.forEach(function(s) {
11478
- mdatSize += s.units.reduce(function(t, c) {
11479
- return t + c.byteLength;
11480
- }, 0);
11481
- mdatSize += s.units.length * 4;
11482
- });
11483
- }
10708
+ samples.forEach(function(s) {
10709
+ mdatSize += s.units.reduce(function(t, c) {
10710
+ return t + c.byteLength;
10711
+ }, 0);
10712
+ mdatSize += s.units.length * 4;
10713
+ });
11484
10714
  var mdata = new Uint8Array(mdatSize);
11485
- if (isAV01) {
11486
- for (var i = 0, l = samples.length, offset = 0, sample; i < l; i++) {
11487
- sample = samples[i];
11488
- mdata.set(sample.data, offset);
11489
- sample.size = sample.data.byteLength;
11490
- offset += sample.size;
11491
- }
11492
- } else {
11493
- var mdatView = new DataView(mdata.buffer);
11494
- var _loop = function _loop2(_offset2, _sample2) {
11495
- _sample2 = samples[_i];
11496
- var sampleSize = 0;
11497
- _sample2.units.forEach(function(u) {
11498
- mdatView.setUint32(_offset2, u.byteLength);
11499
- _offset2 += 4;
11500
- mdata.set(u, _offset2);
11501
- _offset2 += u.byteLength;
11502
- sampleSize += 4 + u.byteLength;
11503
- });
11504
- _sample2.size = sampleSize;
11505
- _offset = _offset2, _sample = _sample2;
11506
- };
11507
- for (var _i = 0, _l = samples.length, _offset = 0, _sample; _i < _l; _i++) {
11508
- _loop(_offset, _sample);
11509
- }
10715
+ var mdatView = new DataView(mdata.buffer);
10716
+ var _loop = function _loop2(_offset, _sample) {
10717
+ _sample = samples[i];
10718
+ var sampleSize = 0;
10719
+ _sample.units.forEach(function(u) {
10720
+ mdatView.setUint32(_offset, u.byteLength);
10721
+ _offset += 4;
10722
+ mdata.set(u, _offset);
10723
+ _offset += u.byteLength;
10724
+ sampleSize += 4 + u.byteLength;
10725
+ });
10726
+ _sample.size = sampleSize;
10727
+ offset = _offset, sample = _sample;
10728
+ };
10729
+ for (var i = 0, l = samples.length, offset = 0, sample; i < l; i++) {
10730
+ _loop(offset, sample);
11510
10731
  }
11511
10732
  var mdat = MP4.mdat(mdata);
11512
10733
  var moof = MP4.moof([track]);
@@ -11665,11 +10886,11 @@
11665
10886
  });
11666
10887
  var logger$3 = new Logger$2("Transmuxer");
11667
10888
  var Transmuxer = /* @__PURE__ */ function() {
11668
- function Transmuxer2(hls, isMP4, needRemux, fixerConfig) {
10889
+ function Transmuxer2(hls, isMP4, needRemux) {
11669
10890
  _classCallCheck$3(this, Transmuxer2);
11670
10891
  _defineProperty$3(this, "_initSegmentId", "");
11671
10892
  this.hls = hls;
11672
- this._demuxer = isMP4 ? new FMP4Demuxer() : new TsDemuxer(null, null, null, fixerConfig);
10893
+ this._demuxer = isMP4 ? new FMP4Demuxer() : new TsDemuxer();
11673
10894
  this._isMP4 = isMP4;
11674
10895
  if (needRemux)
11675
10896
  this._remuxer = new FMP4Remuxer(this._demuxer.videoTrack, this._demuxer.audioTrack);
@@ -11824,7 +11045,7 @@
11824
11045
  }]);
11825
11046
  return Transmuxer2;
11826
11047
  }();
11827
- var _excluded$1 = ["data"], _excluded2 = ["data"];
11048
+ var _excluded = ["data"], _excluded2 = ["data"];
11828
11049
  var logger$2 = new Logger$2("BufferService");
11829
11050
  var BufferService = /* @__PURE__ */ function() {
11830
11051
  function BufferService2(hls) {
@@ -11936,11 +11157,11 @@
11936
11157
  return;
11937
11158
  if (TsDemuxer.probe(chunk)) {
11938
11159
  if (!this._transmuxer)
11939
- this._transmuxer = new Transmuxer(this.hls, false, !this._softVideo, this.hls.config.fixerConfig);
11160
+ this._transmuxer = new Transmuxer(this.hls, false, !this._softVideo);
11940
11161
  } else if (MP4Parser.probe(chunk)) {
11941
11162
  if (this._softVideo) {
11942
11163
  if (!this._transmuxer)
11943
- this._transmuxer = new Transmuxer(this.hls, true, null, this.hls.config.fixerConfig);
11164
+ this._transmuxer = new Transmuxer(this.hls, true);
11944
11165
  } else {
11945
11166
  this._directAppend = true;
11946
11167
  var mix = false;
@@ -11990,8 +11211,7 @@
11990
11211
  key: "appendBuffer",
11991
11212
  value: function() {
11992
11213
  var _appendBuffer = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2(segment, audioSegment, videoChunk, audioChunk, discontinuity, contiguous, startTime) {
11993
- var _this2 = this;
11994
- var afterAppend, p, needInit, _this$_transmuxer$tra, _this$_transmuxer$tra2, video, audio, isFirstAppend, mse, _p, videoData, videoRest, audioData, audioRest;
11214
+ var p, needInit, _this$_transmuxer$tra, _this$_transmuxer$tra2, video, audio, isFirstAppend, mse, _p, videoData, videoRest, audioData, audioRest;
11995
11215
  return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
11996
11216
  while (1)
11997
11217
  switch (_context2.prev = _context2.next) {
@@ -12002,18 +11222,8 @@
12002
11222
  }
12003
11223
  return _context2.abrupt("return");
12004
11224
  case 2:
12005
- afterAppend = function afterAppend2() {
12006
- var _this2$hls;
12007
- if ((_this2$hls = _this2.hls) !== null && _this2$hls !== void 0 && _this2$hls.emit) {
12008
- var _this2$hls2;
12009
- (_this2$hls2 = _this2.hls) === null || _this2$hls2 === void 0 ? void 0 : _this2$hls2.emit(EVENT.APPEND_BUFFER, {
12010
- start: segment.start,
12011
- end: segment.end
12012
- });
12013
- }
12014
- };
12015
11225
  if (!this._directAppend) {
12016
- _context2.next = 8;
11226
+ _context2.next = 7;
12017
11227
  break;
12018
11228
  }
12019
11229
  p = [];
@@ -12021,8 +11231,8 @@
12021
11231
  p.push(this._mse.append(MSE.VIDEO, videoChunk));
12022
11232
  if (audioChunk)
12023
11233
  p.push(this._mse.append(MSE.AUDIO, audioChunk));
12024
- return _context2.abrupt("return", Promise.all(p).then(afterAppend));
12025
- case 8:
11234
+ return _context2.abrupt("return", Promise.all(p));
11235
+ case 7:
12026
11236
  needInit = this._needInitSegment || discontinuity;
12027
11237
  _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];
12028
11238
  if (audioChunk && audioSegment) {
@@ -12038,17 +11248,16 @@
12038
11248
  this.hls.emit(Event$1.NO_AUDIO_TRACK);
12039
11249
  }
12040
11250
  if (!this._softVideo) {
12041
- _context2.next = 20;
11251
+ _context2.next = 18;
12042
11252
  break;
12043
11253
  }
12044
11254
  this._softVideo.appendBuffer(video, audio);
12045
11255
  this._needInitSegment = false;
12046
- afterAppend();
12047
- _context2.next = 30;
11256
+ _context2.next = 28;
12048
11257
  break;
12049
- case 20:
11258
+ case 18:
12050
11259
  if (!this._mse) {
12051
- _context2.next = 30;
11260
+ _context2.next = 28;
12052
11261
  break;
12053
11262
  }
12054
11263
  isFirstAppend = !this._sourceCreated;
@@ -12064,15 +11273,15 @@
12064
11273
  });
12065
11274
  }
12066
11275
  if (video) {
12067
- videoData = video.data, videoRest = _objectWithoutProperties$1(video, _excluded$1);
11276
+ videoData = video.data, videoRest = _objectWithoutProperties$1(video, _excluded);
12068
11277
  _p.push(mse.append(MSE.VIDEO, videoData, videoRest));
12069
11278
  }
12070
11279
  if (audio) {
12071
11280
  audioData = audio.data, audioRest = _objectWithoutProperties$1(audio, _excluded2);
12072
11281
  _p.push(mse.append(MSE.AUDIO, audioData, audioRest));
12073
11282
  }
12074
- return _context2.abrupt("return", Promise.all(_p).then(afterAppend));
12075
- case 30:
11283
+ return _context2.abrupt("return", Promise.all(_p));
11284
+ case 28:
12076
11285
  case "end":
12077
11286
  return _context2.stop();
12078
11287
  }
@@ -12087,7 +11296,7 @@
12087
11296
  key: "removeBuffer",
12088
11297
  value: function() {
12089
11298
  var _removeBuffer = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee3() {
12090
- var _this3 = this;
11299
+ var _this2 = this;
12091
11300
  var start, end, media, _args3 = arguments;
12092
11301
  return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
12093
11302
  while (1)
@@ -12103,7 +11312,7 @@
12103
11312
  return _context3.abrupt("return");
12104
11313
  case 5:
12105
11314
  return _context3.abrupt("return", this._mse.clearBuffer(start, end).then(function() {
12106
- return _this3.hls.emit(EVENT.REMOVE_BUFFER, {
11315
+ return _this2.hls.emit(EVENT.REMOVE_BUFFER, {
12107
11316
  start,
12108
11317
  end,
12109
11318
  removeEnd: end
@@ -12284,51 +11493,30 @@
12284
11493
  return setLiveSeekableRange;
12285
11494
  }()
12286
11495
  }, {
12287
- key: "detachMedia",
11496
+ key: "destroy",
12288
11497
  value: function() {
12289
- var _detachMedia = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee9() {
11498
+ var _destroy = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee9() {
11499
+ var _this$_decryptor;
12290
11500
  return _regeneratorRuntime$1().wrap(function _callee9$(_context9) {
12291
11501
  while (1)
12292
11502
  switch (_context9.prev = _context9.next) {
12293
11503
  case 0:
11504
+ (_this$_decryptor = this._decryptor) === null || _this$_decryptor === void 0 ? void 0 : _this$_decryptor.destroy();
12294
11505
  if (!this._mse) {
12295
- _context9.next = 3;
11506
+ _context9.next = 4;
12296
11507
  break;
12297
11508
  }
12298
- _context9.next = 3;
11509
+ _context9.next = 4;
12299
11510
  return this._mse.unbindMedia();
12300
- case 3:
12301
- case "end":
12302
- return _context9.stop();
12303
- }
12304
- }, _callee9, this);
12305
- }));
12306
- function detachMedia() {
12307
- return _detachMedia.apply(this, arguments);
12308
- }
12309
- return detachMedia;
12310
- }()
12311
- }, {
12312
- key: "destroy",
12313
- value: function() {
12314
- var _destroy = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee10() {
12315
- var _this$_decryptor;
12316
- return _regeneratorRuntime$1().wrap(function _callee10$(_context10) {
12317
- while (1)
12318
- switch (_context10.prev = _context10.next) {
12319
- case 0:
12320
- (_this$_decryptor = this._decryptor) === null || _this$_decryptor === void 0 ? void 0 : _this$_decryptor.destroy();
12321
- _context10.next = 3;
12322
- return this.detachMedia();
12323
- case 3:
11511
+ case 4:
12324
11512
  this._decryptor = null;
12325
11513
  this._mse = null;
12326
11514
  this._softVideo = null;
12327
- case 6:
11515
+ case 7:
12328
11516
  case "end":
12329
- return _context10.stop();
11517
+ return _context9.stop();
12330
11518
  }
12331
- }, _callee10, this);
11519
+ }, _callee9, this);
12332
11520
  }));
12333
11521
  function destroy() {
12334
11522
  return _destroy.apply(this, arguments);
@@ -12416,11 +11604,7 @@
12416
11604
  minSegmentsStartPlay: 3,
12417
11605
  preferMMS: false,
12418
11606
  preferMMSStreaming: false,
12419
- mseLowLatency: true,
12420
- fixerConfig: {
12421
- forceFixLargeGap: false,
12422
- largeGapThreshold: 5
12423
- }
11607
+ mseLowLatency: true
12424
11608
  }, cfg), {}, {
12425
11609
  media
12426
11610
  });
@@ -12535,8 +11719,6 @@
12535
11719
  _defineProperty$3(this, "lowLatency", false);
12536
11720
  _defineProperty$3(this, "endPartIndex", 0);
12537
11721
  _defineProperty$3(this, "segments", []);
12538
- _defineProperty$3(this, "dateRanges", {});
12539
- _defineProperty$3(this, "skippedSegments", 0);
12540
11722
  });
12541
11723
  var MediaSegment = /* @__PURE__ */ function() {
12542
11724
  function MediaSegment2(parentUrl) {
@@ -12658,31 +11840,6 @@
12658
11840
  }]);
12659
11841
  return MediaSegmentKey2;
12660
11842
  }();
12661
- var HlsUrlParameters = /* @__PURE__ */ function() {
12662
- function HlsUrlParameters2(msn, part, skip) {
12663
- _classCallCheck$3(this, HlsUrlParameters2);
12664
- this.msn = msn;
12665
- this.part = part;
12666
- this.skip = skip;
12667
- }
12668
- _createClass$3(HlsUrlParameters2, [{
12669
- key: "addDirectives",
12670
- value: function addDirectives(uri) {
12671
- var url = new self.URL(uri);
12672
- if (this.msn !== void 0) {
12673
- url.searchParams.set("_HLS_msn", this.msn.toString());
12674
- }
12675
- if (this.part) {
12676
- url.searchParams.set("_HLS_part", this.part.toString());
12677
- }
12678
- if (this.skip) {
12679
- url.searchParams.set("_HLS_skip", this.skip);
12680
- }
12681
- return url.href;
12682
- }
12683
- }]);
12684
- return HlsUrlParameters2;
12685
- }();
12686
11843
  var REGEXP_TAG = /^#(EXT[^:]*)(?::(.*))?$/;
12687
11844
  var REGEXP_ATTR = /([^=]+)=(?:"([^"]*)"|([^",]*))(?:,|$)/g;
12688
11845
  var REGEXP_ABSOLUTE_URL = /^(?:[a-zA-Z0-9+\-.]+:)?\/\//;
@@ -12733,38 +11890,6 @@
12733
11890
  }
12734
11891
  }
12735
11892
  }
12736
- function isValidDaterange(attr, dateRangeWithSameId) {
12737
- var _badValueForSameId;
12738
- if (dateRangeWithSameId) {
12739
- for (var key in dateRangeWithSameId) {
12740
- if (Object.prototype.hasOwnProperty.call(dateRangeWithSameId, key) && attr[key] !== dateRangeWithSameId[key]) {
12741
- _badValueForSameId = key;
12742
- break;
12743
- }
12744
- }
12745
- }
12746
- var duration = null;
12747
- if (attr.DURATION) {
12748
- duration = parseFloat(attr.DURATION);
12749
- if (!Number.isFinite(duration)) {
12750
- duration = null;
12751
- } else if (attr._endDate) {
12752
- duration = (attr._endDate.getTime() - attr._startDate.getTime()) / 1e3;
12753
- }
12754
- }
12755
- var cue = enumeratedStringList(attr.CUE || attr["X-CUE"], {
12756
- pre: false,
12757
- post: false,
12758
- once: false
12759
- });
12760
- 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);
12761
- }
12762
- function enumeratedStringList(attrValue, dict) {
12763
- return (attrValue ? attrValue.split(/[ ,]+/) : []).reduce(function(result, identifier) {
12764
- result[identifier.toLowerCase()] = true;
12765
- return result;
12766
- }, dict);
12767
- }
12768
11893
  function parseMasterPlaylist(lines, parentUrl) {
12769
11894
  var master = new MasterPlaylist();
12770
11895
  var index = 0;
@@ -12873,6 +11998,9 @@
12873
11998
  var endOfList = false;
12874
11999
  var partSegmentIndex = 0;
12875
12000
  while (line = lines[index++]) {
12001
+ if (endOfList) {
12002
+ break;
12003
+ }
12876
12004
  if (line[0] !== "#") {
12877
12005
  if (media.lowLatency) {
12878
12006
  curSN++;
@@ -12921,11 +12049,16 @@
12921
12049
  media.canBlockReload = _attr["CAN-BLOCK-RELOAD"] === "YES";
12922
12050
  media.partHoldBack = parseFloat(_attr["PART-HOLD-BACK"] || 0);
12923
12051
  media.canSkipUntil = parseFloat(_attr["CAN-SKIP-UNTIL"] || 0);
12924
- media.canSkipDateRanges = media.canSkipUntil > 0 && _attr["CAN-SKIP-DATERANGES"] === "YES";
12052
+ media.canSkipDateRanges = _attr["CAN-SKIP-DATERANGES"] === "YES";
12925
12053
  }
12926
12054
  break;
12927
12055
  case "ENDLIST":
12928
12056
  {
12057
+ var _lastSegment = media.segments[media.segments.length - 1];
12058
+ if (_lastSegment) {
12059
+ _lastSegment.isLast = true;
12060
+ }
12061
+ media.live = false;
12929
12062
  endOfList = true;
12930
12063
  }
12931
12064
  break;
@@ -12965,15 +12098,6 @@
12965
12098
  }
12966
12099
  break;
12967
12100
  case "PRELOAD-HINT":
12968
- {
12969
- var _attr3 = parseAttr(data);
12970
- media.preloadHint = _attr3;
12971
- if (_attr3["TYPE"] === "PART" && _attr3["URI"]) {
12972
- var tmp = _attr3["URI"].split(".ts")[0].split("-");
12973
- media.nextSN = tmp[3];
12974
- media.nextIndex = tmp[tmp.length - 1];
12975
- }
12976
- }
12977
12101
  break;
12978
12102
  case "PROGRAM-DATE-TIME":
12979
12103
  curSegment.dataTime = data;
@@ -12993,21 +12117,21 @@
12993
12117
  break;
12994
12118
  case "KEY":
12995
12119
  {
12996
- var _attr4 = parseAttr(data);
12997
- if (_attr4.METHOD === "NONE") {
12120
+ var _attr3 = parseAttr(data);
12121
+ if (_attr3.METHOD === "NONE") {
12998
12122
  curKey = null;
12999
12123
  break;
13000
12124
  }
13001
12125
  curKey = new MediaSegmentKey();
13002
- curKey.method = _attr4.METHOD;
13003
- curKey.url = /^blob:/.test(_attr4.URI) ? _attr4.URI : getAbsoluteUrl(_attr4.URI, parentUrl);
13004
- curKey.keyFormat = _attr4.KEYFORMAT || "identity";
13005
- curKey.keyFormatVersions = _attr4.KEYFORMATVERSIONS;
12126
+ curKey.method = _attr3.METHOD;
12127
+ curKey.url = /^blob:/.test(_attr3.URI) ? _attr3.URI : getAbsoluteUrl(_attr3.URI, parentUrl);
12128
+ curKey.keyFormat = _attr3.KEYFORMAT || "identity";
12129
+ curKey.keyFormatVersions = _attr3.KEYFORMATVERSIONS;
13006
12130
  if (!curKey.isSupported()) {
13007
- throw new Error("encrypt ".concat(_attr4.METHOD, "/").concat(_attr4.KEYFORMAT, " is not supported"));
12131
+ throw new Error("encrypt ".concat(_attr3.METHOD, "/").concat(_attr3.KEYFORMAT, " is not supported"));
13008
12132
  }
13009
- if (_attr4.IV) {
13010
- var str = _attr4.IV.slice(2);
12133
+ if (_attr3.IV) {
12134
+ var str = _attr3.IV.slice(2);
13011
12135
  str = (str.length & 1 ? "0" : "") + str;
13012
12136
  curKey.iv = new Uint8Array(str.length / 2);
13013
12137
  for (var i = 0, l = str.length / 2; i < l; i++) {
@@ -13018,10 +12142,10 @@
13018
12142
  break;
13019
12143
  case "MAP":
13020
12144
  {
13021
- var _attr5 = parseAttr(data);
13022
- curSegment.url = getAbsoluteUrl(_attr5.URI, parentUrl);
13023
- if (_attr5.BYTERANGE)
13024
- curSegment.setByteRange(_attr5.BYTERANGE);
12145
+ var _attr4 = parseAttr(data);
12146
+ curSegment.url = getAbsoluteUrl(_attr4.URI, parentUrl);
12147
+ if (_attr4.BYTERANGE)
12148
+ curSegment.setByteRange(_attr4.BYTERANGE);
13025
12149
  curSegment.isInitSegment = true;
13026
12150
  curSegment.sn = 0;
13027
12151
  if (curKey) {
@@ -13031,30 +12155,6 @@
13031
12155
  curSegment = new MediaSegment(parentUrl);
13032
12156
  }
13033
12157
  break;
13034
- case "SKIP":
13035
- {
13036
- var _attr6 = parseAttr(data);
13037
- var skippedSegments = parseInt(_attr6["SKIPPED-SEGMENTS"], 10);
13038
- if (skippedSegments <= Number.MAX_SAFE_INTEGER) {
13039
- media.skippedSegments += skippedSegments;
13040
- curSN += skippedSegments;
13041
- }
13042
- }
13043
- break;
13044
- case "DATERANGE":
13045
- {
13046
- var _attr7 = parseAttr(data);
13047
- var dateRangeWithSameId = media.dateRanges[_attr7.ID];
13048
- _attr7._startDate = dateRangeWithSameId ? dateRangeWithSameId._startDate : new Date(_attr7["START-DATE"]);
13049
- var endDate = (dateRangeWithSameId === null || dateRangeWithSameId === void 0 ? void 0 : dateRangeWithSameId._endDate) || new Date(_attr7.END_DATE);
13050
- if (Number.isFinite(endDate)) {
13051
- _attr7._endDate = endDate;
13052
- }
13053
- if (isValidDaterange(_attr7, dateRangeWithSameId) || media.skippedSegments) {
13054
- media.dateRanges[_attr7.ID] = _attr7;
13055
- }
13056
- }
13057
- break;
13058
12158
  }
13059
12159
  }
13060
12160
  media.segments = media.segments.filter(function(x) {
@@ -13062,14 +12162,11 @@
13062
12162
  });
13063
12163
  var lastSegment = media.segments[media.segments.length - 1];
13064
12164
  if (lastSegment) {
13065
- if (endOfList) {
13066
- lastSegment.isLast = true;
13067
- }
13068
12165
  media.endSN = lastSegment.sn;
13069
12166
  media.endPartIndex = lastSegment.partIndex;
13070
- }
13071
- if (endOfList) {
13072
- media.live = false;
12167
+ if (endOfList && !lastSegment.isLast) {
12168
+ lastSegment.isLast = true;
12169
+ }
13073
12170
  }
13074
12171
  media.totalDuration = totalDuration;
13075
12172
  media.endCC = curCC;
@@ -13248,13 +12345,6 @@
13248
12345
  playlist
13249
12346
  });
13250
12347
  } else {
13251
- if (this._useLowLatency) {
13252
- if (playlist.canBlockReload) {
13253
- this.deliveryDirectives = new HlsUrlParameters(playlist.nextSN, playlist.nextIndex, "");
13254
- } else {
13255
- this.deliveryDirectives = null;
13256
- }
13257
- }
13258
12348
  this.hls.emit(Event$1.HLS_LEVEL_LOADED, {
13259
12349
  playlist
13260
12350
  });
@@ -13311,45 +12401,41 @@
13311
12401
  var retryCount = this.hls.config.pollRetryCount;
13312
12402
  var fn = /* @__PURE__ */ function() {
13313
12403
  var _ref2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee2() {
13314
- var reqUrl, res;
12404
+ var res;
13315
12405
  return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
13316
12406
  while (1)
13317
12407
  switch (_context2.prev = _context2.next) {
13318
12408
  case 0:
13319
12409
  clearTimeout(_this2._timer);
13320
- reqUrl = url;
13321
- _context2.prev = 2;
13322
- if (_this2.deliveryDirectives) {
13323
- reqUrl = _this2.deliveryDirectives.addDirectives(url);
13324
- }
13325
- _context2.next = 6;
13326
- return _this2.load(reqUrl, audioUrl, subtitleUrl);
13327
- case 6:
12410
+ _context2.prev = 1;
12411
+ _context2.next = 4;
12412
+ return _this2.load(url, audioUrl, subtitleUrl);
12413
+ case 4:
13328
12414
  res = _context2.sent;
13329
12415
  if (res[0]) {
13330
- _context2.next = 9;
12416
+ _context2.next = 7;
13331
12417
  break;
13332
12418
  }
13333
12419
  return _context2.abrupt("return");
13334
- case 9:
12420
+ case 7:
13335
12421
  retryCount = _this2.hls.config.pollRetryCount;
13336
12422
  cb(res[0], res[1], res[2]);
13337
- _context2.next = 17;
12423
+ _context2.next = 15;
13338
12424
  break;
13339
- case 13:
13340
- _context2.prev = 13;
13341
- _context2.t0 = _context2["catch"](2);
12425
+ case 11:
12426
+ _context2.prev = 11;
12427
+ _context2.t0 = _context2["catch"](1);
13342
12428
  retryCount--;
13343
12429
  if (retryCount <= 0) {
13344
12430
  errorCb(_context2.t0);
13345
12431
  }
13346
- case 17:
12432
+ case 15:
13347
12433
  _this2._timer = setTimeout(fn, time);
13348
- case 18:
12434
+ case 16:
13349
12435
  case "end":
13350
12436
  return _context2.stop();
13351
12437
  }
13352
- }, _callee2, null, [[2, 13]]);
12438
+ }, _callee2, null, [[1, 11]]);
13353
12439
  }));
13354
12440
  return function fn2() {
13355
12441
  return _ref2.apply(this, arguments);
@@ -13879,7 +12965,7 @@
13879
12965
  }, {
13880
12966
  key: "clearOldSegment",
13881
12967
  value: function clearOldSegment() {
13882
- var maxPlaylistSize = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.hls.config.maxPlaylistSize || 50;
12968
+ var maxPlaylistSize = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 50;
13883
12969
  var stream = this.currentStream;
13884
12970
  if (!this.dvrWindow || !stream)
13885
12971
  return;
@@ -14177,7 +13263,7 @@
14177
13263
  _defineProperty$3(_assertThisInitialized$2(_this), "_switchUrlOpts", null);
14178
13264
  _defineProperty$3(_assertThisInitialized$2(_this), "_isProcessQuotaExceeded", false);
14179
13265
  _defineProperty$3(_assertThisInitialized$2(_this), "_loadSegment", /* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee() {
14180
- var _this$_playlist, nextSegment, lastSegment, _assertThisInitialize, config, minFrameDuration, maxBufferThroughout, bInfo, bufferThroughout;
13266
+ var nextSeg, _assertThisInitialize, config, bInfo, bufferThroughout;
14181
13267
  return _regeneratorRuntime$1().wrap(function _callee$(_context) {
14182
13268
  while (1)
14183
13269
  switch (_context.prev = _context.next) {
@@ -14188,44 +13274,42 @@
14188
13274
  }
14189
13275
  return _context.abrupt("return");
14190
13276
  case 2:
14191
- _this$_playlist = _this._playlist, nextSegment = _this$_playlist.nextSegment, lastSegment = _this$_playlist.lastSegment;
13277
+ nextSeg = _this._playlist.nextSegment;
14192
13278
  _assertThisInitialize = _assertThisInitialized$2(_this), config = _assertThisInitialize.config;
14193
- minFrameDuration = 0.016;
14194
- maxBufferThroughout = Math.min(Math.max((lastSegment === null || lastSegment === void 0 ? void 0 : lastSegment.duration) - minFrameDuration / 2 || 0, minFrameDuration), 0.1);
14195
- if (nextSegment) {
14196
- _context.next = 8;
13279
+ if (nextSeg) {
13280
+ _context.next = 6;
14197
13281
  break;
14198
13282
  }
14199
13283
  return _context.abrupt("return");
14200
- case 8:
13284
+ case 6:
14201
13285
  if (_this.isLive) {
14202
- _context.next = 18;
13286
+ _context.next = 16;
14203
13287
  break;
14204
13288
  }
14205
13289
  bInfo = _this.bufferInfo();
14206
13290
  if (_this.media.paused && !_this.media.currentTime) {
14207
13291
  bInfo = _this.bufferInfo(bInfo.nextStart || 0.5);
14208
13292
  }
14209
- bufferThroughout = Math.abs(bInfo.end - _this.media.duration) < maxBufferThroughout;
13293
+ bufferThroughout = Math.abs(bInfo.end - _this.media.duration) < 0.1;
14210
13294
  if (!(bInfo.remaining >= config.preloadTime || bufferThroughout)) {
14211
- _context.next = 15;
13295
+ _context.next = 13;
14212
13296
  break;
14213
13297
  }
14214
13298
  _this._tryEos();
14215
13299
  return _context.abrupt("return");
14216
- case 15:
13300
+ case 13:
14217
13301
  if (!(config.preferMMSStreaming && !_this._bufferService.msStreaming)) {
14218
- _context.next = 17;
13302
+ _context.next = 15;
14219
13303
  break;
14220
13304
  }
14221
13305
  return _context.abrupt("return");
14222
- case 17:
14223
- if (!_this._urlSwitching && _this._prevSegSn !== nextSegment.sn - 1 && bInfo.end && Math.abs(nextSegment.start - bInfo.end) > 1) {
13306
+ case 15:
13307
+ if (!_this._urlSwitching && _this._prevSegSn !== nextSeg.sn - 1 && bInfo.end && Math.abs(nextSeg.start - bInfo.end) > 1) {
14224
13308
  _this._playlist.setNextSegmentByIndex(_this._playlist.findSegmentIndexByTime(bInfo.end + 0.1));
14225
13309
  }
14226
- case 18:
13310
+ case 16:
14227
13311
  return _context.abrupt("return", _this._loadSegmentDirect());
14228
- case 19:
13312
+ case 17:
14229
13313
  case "end":
14230
13314
  return _context.stop();
14231
13315
  }
@@ -14390,6 +13474,7 @@
14390
13474
  return;
14391
13475
  _this._startTick();
14392
13476
  var media = _this.media;
13477
+ var buffered = Buffer$1.get(media);
14393
13478
  var segLoaderError = _this._segmentLoader.error;
14394
13479
  _this._onCheckQuotaExceeded();
14395
13480
  if (_this._isProcessQuotaExceeded) {
@@ -14406,7 +13491,7 @@
14406
13491
  }
14407
13492
  return;
14408
13493
  }
14409
- if (media.readyState) {
13494
+ if (Buffer$1.end(buffered) >= 0.1 && media.readyState) {
14410
13495
  if (isMediaPlaying(media)) {
14411
13496
  _this._loadSegment();
14412
13497
  if (_this._gapService) {
@@ -14472,12 +13557,6 @@
14472
13557
  var _this$_bufferService;
14473
13558
  return (_this$_bufferService = this._bufferService) === null || _this$_bufferService === void 0 ? void 0 : _this$_bufferService.baseDts;
14474
13559
  }
14475
- }, {
14476
- key: "abrSwitchPoint",
14477
- get: function get() {
14478
- var targetSeg = this._urlSwitching ? this._playlist.currentSegment : this._playlist.nextSegment;
14479
- return targetSeg ? targetSeg.start + targetSeg.duration / 2 : null;
14480
- }
14481
13560
  }, {
14482
13561
  key: "speedInfo",
14483
13562
  value: function speedInfo() {
@@ -14503,37 +13582,30 @@
14503
13582
  }, {
14504
13583
  key: "load",
14505
13584
  value: function() {
14506
- var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee4() {
14507
- var url, options, reuseMse, _args4 = arguments;
13585
+ var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee4(url) {
13586
+ var reuseMse, _args4 = arguments;
14508
13587
  return _regeneratorRuntime$1().wrap(function _callee4$(_context4) {
14509
13588
  while (1)
14510
13589
  switch (_context4.prev = _context4.next) {
14511
13590
  case 0:
14512
- url = _args4.length > 0 && _args4[0] !== void 0 ? _args4[0] : "";
14513
- options = _args4.length > 1 && _args4[1] !== void 0 ? _args4[1] : {};
14514
- reuseMse = typeof options === "boolean" ? options : !!(options !== null && options !== void 0 && options.reuseMse);
14515
- if (_typeof$2(options) === "object" && options !== null && options !== void 0 && options.clearSwitchStatus) {
14516
- this._urlSwitching = false;
14517
- this._switchUrlOpts = null;
14518
- this.config.startTime = void 0;
14519
- }
13591
+ reuseMse = _args4.length > 1 && _args4[1] !== void 0 ? _args4[1] : false;
14520
13592
  if (url)
14521
13593
  this.config.url = url;
14522
13594
  url = this.config.url;
14523
- _context4.next = 8;
13595
+ _context4.next = 5;
14524
13596
  return this._reset(reuseMse);
14525
- case 8:
14526
- _context4.next = 10;
13597
+ case 5:
13598
+ _context4.next = 7;
14527
13599
  return this._loadData(url);
14528
- case 10:
13600
+ case 7:
14529
13601
  this._startTick();
14530
- case 11:
13602
+ case 8:
14531
13603
  case "end":
14532
13604
  return _context4.stop();
14533
13605
  }
14534
13606
  }, _callee4, this);
14535
13607
  }));
14536
- function load() {
13608
+ function load(_x) {
14537
13609
  return _load.apply(this, arguments);
14538
13610
  }
14539
13611
  return load;
@@ -14542,7 +13614,7 @@
14542
13614
  key: "_loadData",
14543
13615
  value: function() {
14544
13616
  var _loadData2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee5(url) {
14545
- var manifest, currentStream, preIndex, _this$_switchUrlOpts, _this$_switchUrlOpts3, _this$_switchUrlOpts4, _this$_switchUrlOpts2, switchTimePoint, segIdx, nextSeg, bufferClearStartPoint, startTime, _this$_switchUrlOpts5;
13617
+ var manifest, currentStream, _this$_switchUrlOpts, _this$_switchUrlOpts2, switchTimePoint, segIdx, nextSeg, bufferClearStartPoint, preIndex, startTime, _this$_switchUrlOpts3;
14546
13618
  return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
14547
13619
  while (1)
14548
13620
  switch (_context5.prev = _context5.next) {
@@ -14563,46 +13635,41 @@
14563
13635
  case 5:
14564
13636
  manifest = _context5.sent;
14565
13637
  currentStream = this._playlist.currentStream;
14566
- if (!this._urlSwitching) {
14567
- _context5.next = 23;
14568
- break;
14569
- }
14570
- if (!this.isLive) {
14571
- _context5.next = 14;
13638
+ if (!(this._urlSwitching && !this.isLive)) {
13639
+ _context5.next = 17;
14572
13640
  break;
14573
13641
  }
14574
- preIndex = this._playlist.setNextSegmentBySN(this._prevSegSn);
14575
- logger.log("segment nb=".concat(this._prevSegSn, " index of ").concat(preIndex, " in the new playlist"));
14576
- if (preIndex === -1) {
14577
- this._prevSegCc = null;
14578
- this._prevSegSn = null;
14579
- }
14580
- _context5.next = 23;
14581
- break;
14582
- case 14:
14583
13642
  if (currentStream.bitrate === 0 && (_this$_switchUrlOpts = this._switchUrlOpts) !== null && _this$_switchUrlOpts !== void 0 && _this$_switchUrlOpts.bitrate) {
14584
13643
  currentStream.bitrate = (_this$_switchUrlOpts2 = this._switchUrlOpts) === null || _this$_switchUrlOpts2 === void 0 ? void 0 : _this$_switchUrlOpts2.bitrate;
14585
13644
  }
14586
- 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();
13645
+ switchTimePoint = this._getSeamlessSwitchPoint();
14587
13646
  this.config.startTime = switchTimePoint;
14588
13647
  segIdx = this._playlist.findSegmentIndexByTime(switchTimePoint);
14589
13648
  nextSeg = this._playlist.getSegmentByIndex(segIdx + 1);
14590
13649
  if (!nextSeg) {
14591
- _context5.next = 23;
13650
+ _context5.next = 17;
14592
13651
  break;
14593
13652
  }
14594
13653
  bufferClearStartPoint = nextSeg.start;
14595
- _context5.next = 23;
13654
+ _context5.next = 17;
14596
13655
  return this._bufferService.removeBuffer(bufferClearStartPoint);
14597
- case 23:
13656
+ case 17:
13657
+ if (this._urlSwitching && this.isLive) {
13658
+ preIndex = this._playlist.setNextSegmentBySN(this._prevSegSn);
13659
+ logger.log("segment nb=".concat(this._prevSegSn, " index of ").concat(preIndex, " in the new playlist"));
13660
+ if (preIndex === -1) {
13661
+ this._prevSegCc = null;
13662
+ this._prevSegSn = null;
13663
+ }
13664
+ }
14598
13665
  if (manifest) {
14599
- _context5.next = 25;
13666
+ _context5.next = 20;
14600
13667
  break;
14601
13668
  }
14602
13669
  return _context5.abrupt("return");
14603
- case 25:
13670
+ case 20:
14604
13671
  if (!this.isLive) {
14605
- _context5.next = 36;
13672
+ _context5.next = 31;
14606
13673
  break;
14607
13674
  }
14608
13675
  this._bufferService.setLiveSeekableRange(0, 4294967295);
@@ -14615,35 +13682,35 @@
14615
13682
  if (!manifest.isMaster)
14616
13683
  this._pollM3U8(url);
14617
13684
  if (!(this._playlist.nbSegments < this.config.minSegmentsStartPlay)) {
14618
- _context5.next = 33;
13685
+ _context5.next = 28;
14619
13686
  break;
14620
13687
  }
14621
13688
  return _context5.abrupt("return");
14622
- case 33:
14623
- _context5.next = 35;
13689
+ case 28:
13690
+ _context5.next = 30;
14624
13691
  return this._loadSegment();
14625
- case 35:
13692
+ case 30:
14626
13693
  return _context5.abrupt("return");
14627
- case 36:
14628
- _context5.next = 38;
13694
+ case 31:
13695
+ _context5.next = 33;
14629
13696
  return this._bufferService.updateDuration(currentStream.totalDuration);
14630
- case 38:
13697
+ case 33:
14631
13698
  startTime = this.config.startTime;
14632
13699
  if (startTime) {
14633
- if (!((_this$_switchUrlOpts5 = this._switchUrlOpts) !== null && _this$_switchUrlOpts5 !== void 0 && _this$_switchUrlOpts5.seamless)) {
13700
+ if (!((_this$_switchUrlOpts3 = this._switchUrlOpts) !== null && _this$_switchUrlOpts3 !== void 0 && _this$_switchUrlOpts3.seamless)) {
14634
13701
  this.media.currentTime = startTime;
14635
13702
  }
14636
13703
  this._playlist.setNextSegmentByIndex(this._playlist.findSegmentIndexByTime(startTime) || 0);
14637
13704
  }
14638
- _context5.next = 42;
13705
+ _context5.next = 37;
14639
13706
  return this._loadSegment();
14640
- case 42:
13707
+ case 37:
14641
13708
  case "end":
14642
13709
  return _context5.stop();
14643
13710
  }
14644
13711
  }, _callee5, this);
14645
13712
  }));
14646
- function _loadData(_x) {
13713
+ function _loadData(_x2) {
14647
13714
  return _loadData2.apply(this, arguments);
14648
13715
  }
14649
13716
  return _loadData;
@@ -14657,20 +13724,18 @@
14657
13724
  switch (_context6.prev = _context6.next) {
14658
13725
  case 0:
14659
13726
  this.config.startTime = 0;
14660
- this._urlSwitching = false;
14661
- this._switchUrlOpts = null;
14662
- _context6.next = 5;
13727
+ _context6.next = 3;
14663
13728
  return this.load();
14664
- case 5:
13729
+ case 3:
14665
13730
  this._reloadOnPlay = false;
14666
13731
  return _context6.abrupt("return", this.media.play(!isPlayEmit));
14667
- case 7:
13732
+ case 5:
14668
13733
  case "end":
14669
13734
  return _context6.stop();
14670
13735
  }
14671
13736
  }, _callee6, this);
14672
13737
  }));
14673
- function replay(_x2) {
13738
+ function replay(_x3) {
14674
13739
  return _replay.apply(this, arguments);
14675
13740
  }
14676
13741
  return replay;
@@ -14775,7 +13840,7 @@
14775
13840
  }
14776
13841
  }, _callee7, this, [[18, 29]]);
14777
13842
  }));
14778
- function switchURL(_x3) {
13843
+ function switchURL(_x4) {
14779
13844
  return _switchURL.apply(this, arguments);
14780
13845
  }
14781
13846
  return switchURL;
@@ -14861,7 +13926,7 @@
14861
13926
  }
14862
13927
  }, _callee8, this, [[8, 16], [21, 31]]);
14863
13928
  }));
14864
- function switchStream(_x4) {
13929
+ function switchStream(_x5) {
14865
13930
  return _switchStream.apply(this, arguments);
14866
13931
  }
14867
13932
  return switchStream;
@@ -14947,7 +14012,7 @@
14947
14012
  }
14948
14013
  }, _callee9, this, [[10, 18], [22, 32]]);
14949
14014
  }));
14950
- function switchAudioStream(_x5) {
14015
+ function switchAudioStream(_x6) {
14951
14016
  return _switchAudioStream.apply(this, arguments);
14952
14017
  }
14953
14018
  return switchAudioStream;
@@ -14972,50 +14037,25 @@
14972
14037
  }
14973
14038
  }, _callee10, this);
14974
14039
  }));
14975
- function switchSubtitleStream(_x6) {
14040
+ function switchSubtitleStream(_x7) {
14976
14041
  return _switchSubtitleStream.apply(this, arguments);
14977
14042
  }
14978
14043
  return switchSubtitleStream;
14979
14044
  }()
14980
- }, {
14981
- key: "detachMedia",
14982
- value: function() {
14983
- var _detachMedia = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee11() {
14984
- return _regeneratorRuntime$1().wrap(function _callee11$(_context11) {
14985
- while (1)
14986
- switch (_context11.prev = _context11.next) {
14987
- case 0:
14988
- if (!this._bufferService) {
14989
- _context11.next = 3;
14990
- break;
14991
- }
14992
- _context11.next = 3;
14993
- return this._bufferService.detachMedia();
14994
- case 3:
14995
- case "end":
14996
- return _context11.stop();
14997
- }
14998
- }, _callee11, this);
14999
- }));
15000
- function detachMedia() {
15001
- return _detachMedia.apply(this, arguments);
15002
- }
15003
- return detachMedia;
15004
- }()
15005
14045
  }, {
15006
14046
  key: "destroy",
15007
14047
  value: function() {
15008
- var _destroy = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee12() {
14048
+ var _destroy = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee11() {
15009
14049
  var _this$_seiService2;
15010
- return _regeneratorRuntime$1().wrap(function _callee12$(_context12) {
14050
+ return _regeneratorRuntime$1().wrap(function _callee11$(_context11) {
15011
14051
  while (1)
15012
- switch (_context12.prev = _context12.next) {
14052
+ switch (_context11.prev = _context11.next) {
15013
14053
  case 0:
15014
14054
  if (this.media) {
15015
- _context12.next = 2;
14055
+ _context11.next = 2;
15016
14056
  break;
15017
14057
  }
15018
- return _context12.abrupt("return");
14058
+ return _context11.abrupt("return");
15019
14059
  case 2:
15020
14060
  this.removeAllListeners();
15021
14061
  this._playlist.reset();
@@ -15026,15 +14066,15 @@
15026
14066
  this.media.removeEventListener("pause", this._onPause);
15027
14067
  this.media.removeEventListener("seeking", this._onSeeking);
15028
14068
  this.media.removeEventListener("timeupdate", this._onTimeupdate);
15029
- _context12.next = 13;
14069
+ _context11.next = 13;
15030
14070
  return Promise.all([this._clear(), this._bufferService.destroy()]);
15031
14071
  case 13:
15032
14072
  this.media = null;
15033
14073
  case 14:
15034
14074
  case "end":
15035
- return _context12.stop();
14075
+ return _context11.stop();
15036
14076
  }
15037
- }, _callee12, this);
14077
+ }, _callee11, this);
15038
14078
  }));
15039
14079
  function destroy() {
15040
14080
  return _destroy.apply(this, arguments);
@@ -15044,48 +14084,48 @@
15044
14084
  }, {
15045
14085
  key: "_loadM3U8",
15046
14086
  value: function() {
15047
- var _loadM3U = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee13(url) {
14087
+ var _loadM3U = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee12(url) {
15048
14088
  var playlist, _this$config$manifest, _this$config$manifest2, manifest, _ref4, _ref5, _this$_playlist$curre;
15049
- return _regeneratorRuntime$1().wrap(function _callee13$(_context13) {
14089
+ return _regeneratorRuntime$1().wrap(function _callee12$(_context12) {
15050
14090
  while (1)
15051
- switch (_context13.prev = _context13.next) {
14091
+ switch (_context12.prev = _context12.next) {
15052
14092
  case 0:
15053
- _context13.prev = 0;
14093
+ _context12.prev = 0;
15054
14094
  manifest = (_this$config$manifest = this.config.manifestList) === null || _this$config$manifest === void 0 ? void 0 : (_this$config$manifest2 = _this$config$manifest.filter(function(x) {
15055
14095
  return x.url === url;
15056
14096
  })[0]) === null || _this$config$manifest2 === void 0 ? void 0 : _this$config$manifest2.manifest;
15057
14097
  if (!manifest) {
15058
- _context13.next = 6;
14098
+ _context12.next = 6;
15059
14099
  break;
15060
14100
  }
15061
- _context13.t0 = this._manifestLoader.parseText(manifest, url);
15062
- _context13.next = 9;
14101
+ _context12.t0 = this._manifestLoader.parseText(manifest, url);
14102
+ _context12.next = 9;
15063
14103
  break;
15064
14104
  case 6:
15065
- _context13.next = 8;
14105
+ _context12.next = 8;
15066
14106
  return this._manifestLoader.load(url);
15067
14107
  case 8:
15068
- _context13.t0 = _context13.sent;
14108
+ _context12.t0 = _context12.sent;
15069
14109
  case 9:
15070
- _ref4 = _context13.t0;
14110
+ _ref4 = _context12.t0;
15071
14111
  _ref5 = _slicedToArray$1(_ref4, 1);
15072
14112
  playlist = _ref5[0];
15073
- _context13.next = 17;
14113
+ _context12.next = 17;
15074
14114
  break;
15075
14115
  case 14:
15076
- _context13.prev = 14;
15077
- _context13.t1 = _context13["catch"](0);
15078
- throw this._emitError(StreamingError.create(_context13.t1));
14116
+ _context12.prev = 14;
14117
+ _context12.t1 = _context12["catch"](0);
14118
+ throw this._emitError(StreamingError.create(_context12.t1));
15079
14119
  case 17:
15080
14120
  if (playlist) {
15081
- _context13.next = 19;
14121
+ _context12.next = 19;
15082
14122
  break;
15083
14123
  }
15084
- return _context13.abrupt("return");
14124
+ return _context12.abrupt("return");
15085
14125
  case 19:
15086
14126
  this._playlist.upsertPlaylist(playlist);
15087
14127
  if (!playlist.isMaster) {
15088
- _context13.next = 24;
14128
+ _context12.next = 24;
15089
14129
  break;
15090
14130
  }
15091
14131
  if ((_this$_playlist$curre = this._playlist.currentStream.subtitleStreams) !== null && _this$_playlist$curre !== void 0 && _this$_playlist$curre.length) {
@@ -15093,18 +14133,18 @@
15093
14133
  list: this._playlist.currentStream.subtitleStreams
15094
14134
  });
15095
14135
  }
15096
- _context13.next = 24;
14136
+ _context12.next = 24;
15097
14137
  return this._refreshM3U8();
15098
14138
  case 24:
15099
14139
  this.emit(Event$1.STREAM_PARSED);
15100
- return _context13.abrupt("return", playlist);
14140
+ return _context12.abrupt("return", playlist);
15101
14141
  case 26:
15102
14142
  case "end":
15103
- return _context13.stop();
14143
+ return _context12.stop();
15104
14144
  }
15105
- }, _callee13, this, [[0, 14]]);
14145
+ }, _callee12, this, [[0, 14]]);
15106
14146
  }));
15107
- function _loadM3U8(_x7) {
14147
+ function _loadM3U8(_x8) {
15108
14148
  return _loadM3U.apply(this, arguments);
15109
14149
  }
15110
14150
  return _loadM3U8;
@@ -15138,7 +14178,7 @@
15138
14178
  var isEmpty = this._playlist.isEmpty;
15139
14179
  var pollInterval;
15140
14180
  if (this._playlist.lowLatency) {
15141
- pollInterval = (this._playlist.currentStream.partTargetDuration || 0) * 1e3;
14181
+ pollInterval = (this._playlist.currentStream.partTargetDuration * 2 || 0) * 1e3;
15142
14182
  } else {
15143
14183
  var _this$_playlist$lastS;
15144
14184
  pollInterval = (((_this$_playlist$lastS = this._playlist.lastSegment) === null || _this$_playlist$lastS === void 0 ? void 0 : _this$_playlist$lastS.duration) || 0) * 1e3;
@@ -15166,53 +14206,53 @@
15166
14206
  }, {
15167
14207
  key: "_loadSegmentDirect",
15168
14208
  value: function() {
15169
- var _loadSegmentDirect2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee14(loadOnce) {
14209
+ var _loadSegmentDirect2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee13(loadOnce) {
15170
14210
  var seg, appended, cachedError, _this$_playlist$curre2, bufferEnd, sameStream;
15171
- return _regeneratorRuntime$1().wrap(function _callee14$(_context14) {
14211
+ return _regeneratorRuntime$1().wrap(function _callee13$(_context13) {
15172
14212
  while (1)
15173
- switch (_context14.prev = _context14.next) {
14213
+ switch (_context13.prev = _context13.next) {
15174
14214
  case 0:
15175
14215
  seg = this._playlist.nextSegment;
15176
14216
  if (seg) {
15177
- _context14.next = 3;
14217
+ _context13.next = 3;
15178
14218
  break;
15179
14219
  }
15180
- return _context14.abrupt("return");
14220
+ return _context13.abrupt("return");
15181
14221
  case 3:
15182
14222
  appended = false;
15183
14223
  cachedError = null;
15184
- _context14.prev = 5;
14224
+ _context13.prev = 5;
15185
14225
  this._segmentProcessing = true;
15186
14226
  logger.log("load segment, sn:".concat(seg.sn, ", [").concat(seg.start, ", ").concat(seg.end, "], partIndex:").concat(seg.partIndex));
15187
- _context14.next = 10;
14227
+ _context13.next = 10;
15188
14228
  return this._reqAndBufferSegment(seg, this._playlist.getAudioSegment(seg));
15189
14229
  case 10:
15190
- appended = _context14.sent;
15191
- _context14.next = 16;
14230
+ appended = _context13.sent;
14231
+ _context13.next = 16;
15192
14232
  break;
15193
14233
  case 13:
15194
- _context14.prev = 13;
15195
- _context14.t0 = _context14["catch"](5);
15196
- cachedError = _context14.t0;
14234
+ _context13.prev = 13;
14235
+ _context13.t0 = _context13["catch"](5);
14236
+ cachedError = _context13.t0;
15197
14237
  case 16:
15198
- _context14.prev = 16;
14238
+ _context13.prev = 16;
15199
14239
  this._segmentProcessing = false;
15200
- return _context14.finish(16);
14240
+ return _context13.finish(16);
15201
14241
  case 19:
15202
14242
  if (!cachedError) {
15203
- _context14.next = 26;
14243
+ _context13.next = 26;
15204
14244
  break;
15205
14245
  }
15206
14246
  if (!this._bufferService.isFull()) {
15207
- _context14.next = 25;
14247
+ _context13.next = 25;
15208
14248
  break;
15209
14249
  }
15210
14250
  logger.log("load segment, sn:".concat(seg.sn, ", partIndex:").concat(seg.partIndex));
15211
14251
  this._segmentProcessing = true;
15212
14252
  this._isProcessQuotaExceeded = true;
15213
- return _context14.abrupt("return", false);
14253
+ return _context13.abrupt("return", false);
15214
14254
  case 25:
15215
- return _context14.abrupt("return", this._emitError(StreamingError.create(cachedError)));
14255
+ return _context13.abrupt("return", this._emitError(StreamingError.create(cachedError)));
15216
14256
  case 26:
15217
14257
  if (appended) {
15218
14258
  bufferEnd = this.bufferInfo().end;
@@ -15238,14 +14278,14 @@
15238
14278
  this._loadSegment();
15239
14279
  }
15240
14280
  }
15241
- return _context14.abrupt("return", appended);
14281
+ return _context13.abrupt("return", appended);
15242
14282
  case 28:
15243
14283
  case "end":
15244
- return _context14.stop();
14284
+ return _context13.stop();
15245
14285
  }
15246
- }, _callee14, this, [[5, 13, 16, 19]]);
14286
+ }, _callee13, this, [[5, 13, 16, 19]]);
15247
14287
  }));
15248
- function _loadSegmentDirect(_x8) {
14288
+ function _loadSegmentDirect(_x9) {
15249
14289
  return _loadSegmentDirect2.apply(this, arguments);
15250
14290
  }
15251
14291
  return _loadSegmentDirect;
@@ -15253,45 +14293,45 @@
15253
14293
  }, {
15254
14294
  key: "_reqAndBufferSegment",
15255
14295
  value: function() {
15256
- var _reqAndBufferSegment2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee15(seg, audioSeg) {
14296
+ var _reqAndBufferSegment2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee14(seg, audioSeg) {
15257
14297
  var _this$_bufferService2;
15258
14298
  var cc, discontinuity, responses, data, sn, start, stream, before, contiguous, segStart;
15259
- return _regeneratorRuntime$1().wrap(function _callee15$(_context15) {
14299
+ return _regeneratorRuntime$1().wrap(function _callee14$(_context14) {
15260
14300
  while (1)
15261
- switch (_context15.prev = _context15.next) {
14301
+ switch (_context14.prev = _context14.next) {
15262
14302
  case 0:
15263
14303
  cc = seg ? seg.cc : audioSeg.cc;
15264
14304
  discontinuity = this._prevSegCc !== cc;
15265
14305
  responses = [];
15266
- _context15.prev = 3;
15267
- _context15.next = 6;
14306
+ _context14.prev = 3;
14307
+ _context14.next = 6;
15268
14308
  return this._segmentLoader.load(seg, audioSeg, discontinuity);
15269
14309
  case 6:
15270
- responses = _context15.sent;
15271
- _context15.next = 14;
14310
+ responses = _context14.sent;
14311
+ _context14.next = 14;
15272
14312
  break;
15273
14313
  case 9:
15274
- _context15.prev = 9;
15275
- _context15.t0 = _context15["catch"](3);
15276
- _context15.t0.fatal = false;
15277
- this._segmentLoader.error = _context15.t0;
15278
- throw _context15.t0;
14314
+ _context14.prev = 9;
14315
+ _context14.t0 = _context14["catch"](3);
14316
+ _context14.t0.fatal = false;
14317
+ this._segmentLoader.error = _context14.t0;
14318
+ throw _context14.t0;
15279
14319
  case 14:
15280
14320
  if (responses[0]) {
15281
- _context15.next = 16;
14321
+ _context14.next = 16;
15282
14322
  break;
15283
14323
  }
15284
- return _context15.abrupt("return");
14324
+ return _context14.abrupt("return");
15285
14325
  case 16:
15286
- _context15.next = 18;
14326
+ _context14.next = 18;
15287
14327
  return (_this$_bufferService2 = this._bufferService).decryptBuffer.apply(_this$_bufferService2, _toConsumableArray$2(responses));
15288
14328
  case 18:
15289
- data = _context15.sent;
14329
+ data = _context14.sent;
15290
14330
  if (data) {
15291
- _context15.next = 21;
14331
+ _context14.next = 21;
15292
14332
  break;
15293
14333
  }
15294
- return _context15.abrupt("return");
14334
+ return _context14.abrupt("return");
15295
14335
  case 21:
15296
14336
  sn = seg ? seg.sn : audioSeg.sn;
15297
14337
  start = seg ? seg.start : audioSeg.start;
@@ -15305,26 +14345,26 @@
15305
14345
  logger.warn("update the new playlist liveEdge, segment id=".concat(sn, ", buffer start=").concat(segStart, ", liveEdge=").concat(this._playlist.liveEdge));
15306
14346
  start = segStart;
15307
14347
  }
15308
- _context15.next = 30;
14348
+ _context14.next = 30;
15309
14349
  return this._bufferService.appendBuffer(seg, audioSeg, data[0], data[1], discontinuity, contiguous, start);
15310
14350
  case 30:
15311
14351
  this.emit(Event$1.APPEND_COST, {
15312
14352
  elapsed: Date.now() - before,
15313
14353
  url: seg.url
15314
14354
  });
15315
- _context15.next = 33;
14355
+ _context14.next = 33;
15316
14356
  return this._bufferService.evictBuffer(this.config.bufferBehind);
15317
14357
  case 33:
15318
14358
  this._prevSegCc = cc;
15319
14359
  this._prevSegSn = sn;
15320
- return _context15.abrupt("return", true);
14360
+ return _context14.abrupt("return", true);
15321
14361
  case 36:
15322
14362
  case "end":
15323
- return _context15.stop();
14363
+ return _context14.stop();
15324
14364
  }
15325
- }, _callee15, this, [[3, 9]]);
14365
+ }, _callee14, this, [[3, 9]]);
15326
14366
  }));
15327
- function _reqAndBufferSegment(_x9, _x10) {
14367
+ function _reqAndBufferSegment(_x10, _x11) {
15328
14368
  return _reqAndBufferSegment2.apply(this, arguments);
15329
14369
  }
15330
14370
  return _reqAndBufferSegment;
@@ -15332,11 +14372,11 @@
15332
14372
  }, {
15333
14373
  key: "_onCheckQuotaExceeded",
15334
14374
  value: function() {
15335
- var _onCheckQuotaExceeded2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee16() {
14375
+ var _onCheckQuotaExceeded2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee15() {
15336
14376
  var seekTime, buffered, inBuffered, i, bufferBehind, mediaTime;
15337
- return _regeneratorRuntime$1().wrap(function _callee16$(_context16) {
14377
+ return _regeneratorRuntime$1().wrap(function _callee15$(_context15) {
15338
14378
  while (1)
15339
- switch (_context16.prev = _context16.next) {
14379
+ switch (_context15.prev = _context15.next) {
15340
14380
  case 0:
15341
14381
  seekTime = this.media.currentTime;
15342
14382
  buffered = this.media.buffered;
@@ -15344,37 +14384,37 @@
15344
14384
  i = 0;
15345
14385
  case 4:
15346
14386
  if (!(i < buffered.length)) {
15347
- _context16.next = 11;
14387
+ _context15.next = 11;
15348
14388
  break;
15349
14389
  }
15350
14390
  if (!(buffered.start(0) >= seekTime && seekTime < buffered.end(i))) {
15351
- _context16.next = 8;
14391
+ _context15.next = 8;
15352
14392
  break;
15353
14393
  }
15354
14394
  inBuffered = true;
15355
- return _context16.abrupt("break", 11);
14395
+ return _context15.abrupt("break", 11);
15356
14396
  case 8:
15357
14397
  i++;
15358
- _context16.next = 4;
14398
+ _context15.next = 4;
15359
14399
  break;
15360
14400
  case 11:
15361
14401
  if (!this._bufferService.isFull()) {
15362
- _context16.next = 17;
14402
+ _context15.next = 17;
15363
14403
  break;
15364
14404
  }
15365
14405
  bufferBehind = inBuffered ? this.config.bufferBehind : 5;
15366
14406
  mediaTime = this.media.currentTime;
15367
14407
  if (!(mediaTime - bufferBehind > 0)) {
15368
- _context16.next = 17;
14408
+ _context15.next = 17;
15369
14409
  break;
15370
14410
  }
15371
- _context16.next = 17;
14411
+ _context15.next = 17;
15372
14412
  return this._bufferService.removeBuffer(0, mediaTime - bufferBehind);
15373
14413
  case 17:
15374
14414
  case "end":
15375
- return _context16.stop();
14415
+ return _context15.stop();
15376
14416
  }
15377
- }, _callee16, this);
14417
+ }, _callee15, this);
15378
14418
  }));
15379
14419
  function _onCheckQuotaExceeded() {
15380
14420
  return _onCheckQuotaExceeded2.apply(this, arguments);
@@ -15392,22 +14432,22 @@
15392
14432
  }, {
15393
14433
  key: "_clear",
15394
14434
  value: function() {
15395
- var _clear2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee17() {
15396
- return _regeneratorRuntime$1().wrap(function _callee17$(_context17) {
14435
+ var _clear2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee16() {
14436
+ return _regeneratorRuntime$1().wrap(function _callee16$(_context16) {
15397
14437
  while (1)
15398
- switch (_context17.prev = _context17.next) {
14438
+ switch (_context16.prev = _context16.next) {
15399
14439
  case 0:
15400
14440
  clearTimeout(this._disconnectTimer);
15401
14441
  this._stopTick();
15402
- _context17.next = 4;
14442
+ _context16.next = 4;
15403
14443
  return Promise.all([this._segmentLoader.cancel(), this._manifestLoader.stopPoll()]);
15404
14444
  case 4:
15405
14445
  this._segmentProcessing = false;
15406
14446
  case 5:
15407
14447
  case "end":
15408
- return _context17.stop();
14448
+ return _context16.stop();
15409
14449
  }
15410
- }, _callee17, this);
14450
+ }, _callee16, this);
15411
14451
  }));
15412
14452
  function _clear() {
15413
14453
  return _clear2.apply(this, arguments);
@@ -15417,14 +14457,14 @@
15417
14457
  }, {
15418
14458
  key: "_reset",
15419
14459
  value: function() {
15420
- var _reset2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee18() {
14460
+ var _reset2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee17() {
15421
14461
  var _this$_seiService3;
15422
- var reuseMse, _args18 = arguments;
15423
- return _regeneratorRuntime$1().wrap(function _callee18$(_context18) {
14462
+ var reuseMse, _args17 = arguments;
14463
+ return _regeneratorRuntime$1().wrap(function _callee17$(_context17) {
15424
14464
  while (1)
15425
- switch (_context18.prev = _context18.next) {
14465
+ switch (_context17.prev = _context17.next) {
15426
14466
  case 0:
15427
- reuseMse = _args18.length > 0 && _args18[0] !== void 0 ? _args18[0] : false;
14467
+ reuseMse = _args17.length > 0 && _args17[0] !== void 0 ? _args17[0] : false;
15428
14468
  this._reloadOnPlay = false;
15429
14469
  this._prevSegSn = null;
15430
14470
  this._prevSegCc = null;
@@ -15433,15 +14473,15 @@
15433
14473
  this._segmentLoader.reset();
15434
14474
  (_this$_seiService3 = this._seiService) === null || _this$_seiService3 === void 0 ? void 0 : _this$_seiService3.reset();
15435
14475
  this._stats.reset();
15436
- _context18.next = 11;
14476
+ _context17.next = 11;
15437
14477
  return this._clear();
15438
14478
  case 11:
15439
- return _context18.abrupt("return", this._bufferService.reset(reuseMse));
14479
+ return _context17.abrupt("return", this._bufferService.reset(reuseMse));
15440
14480
  case 12:
15441
14481
  case "end":
15442
- return _context18.stop();
14482
+ return _context17.stop();
15443
14483
  }
15444
- }, _callee18, this);
14484
+ }, _callee17, this);
15445
14485
  }));
15446
14486
  function _reset() {
15447
14487
  return _reset2.apply(this, arguments);
@@ -15522,8 +14562,8 @@
15522
14562
  value: function _tryEos() {
15523
14563
  var _this$_bufferService3, _this$_bufferService4;
15524
14564
  var media = this.media;
15525
- var _this$_playlist2 = this._playlist, nextSegment = _this$_playlist2.nextSegment, lastSegment = _this$_playlist2.lastSegment;
15526
- 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);
14565
+ var _this$_playlist = this._playlist, nextSegment = _this$_playlist.nextSegment, lastSegment = _this$_playlist.lastSegment;
14566
+ 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);
15527
14567
  if (!eosAllowed) {
15528
14568
  return;
15529
14569
  }
@@ -15559,7 +14599,7 @@
15559
14599
  }]);
15560
14600
  return Hls2;
15561
14601
  }(EventEmitter);
15562
- _defineProperty$3(Hls, "version", "3.0.20-alpha.3");
14602
+ _defineProperty$3(Hls, "version", "3.0.19-rc.0");
15563
14603
  try {
15564
14604
  if (localStorage.getItem("xgd")) {
15565
14605
  Hls.enableLogger();
@@ -15650,7 +14690,6 @@
15650
14690
  }]);
15651
14691
  return PluginExtension2;
15652
14692
  }();
15653
- var _excluded = ["currentTime"];
15654
14693
  function parseSwitchUrlArgs(args, plugin) {
15655
14694
  var player = plugin.player;
15656
14695
  var curTime = player.currentTime;
@@ -15661,14 +14700,9 @@
15661
14700
  case "boolean":
15662
14701
  options.seamless = args;
15663
14702
  break;
15664
- case "object": {
15665
- var currentTime = args.currentTime, rest = _objectWithoutProperties$1(args, _excluded);
15666
- Object.assign(options, rest);
15667
- if (typeof currentTime === "number") {
15668
- options.startTime = currentTime;
15669
- }
14703
+ case "object":
14704
+ Object.assign(options, args);
15670
14705
  break;
15671
- }
15672
14706
  }
15673
14707
  return options;
15674
14708
  }
@@ -15678,11 +14712,10 @@
15678
14712
  function HlsPlugin2() {
15679
14713
  var _this;
15680
14714
  _classCallCheck$3(this, HlsPlugin2);
15681
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
15682
- args[_key] = arguments[_key];
14715
+ for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
14716
+ _args[_key] = arguments[_key];
15683
14717
  }
15684
- _this = _super.call.apply(_super, [this].concat(args));
15685
- _defineProperty$3(_assertThisInitialized$2(_this), "logger", logger);
14718
+ _this = _super.call.apply(_super, [this].concat(_args));
15686
14719
  _defineProperty$3(_assertThisInitialized$2(_this), "hls", null);
15687
14720
  _defineProperty$3(_assertThisInitialized$2(_this), "pluginExtension", null);
15688
14721
  _defineProperty$3(_assertThisInitialized$2(_this), "getStats", function() {
@@ -15694,6 +14727,24 @@
15694
14727
  var lang = _ref.lang;
15695
14728
  (_this$hls2 = _this.hls) === null || _this$hls2 === void 0 ? void 0 : _this$hls2.switchSubtitleStream(lang);
15696
14729
  });
14730
+ _defineProperty$3(_assertThisInitialized$2(_this), "_onSwitchURL", function(url, args) {
14731
+ return new Promise(function(resolve, reject) {
14732
+ var _assertThisInitialize = _assertThisInitialized$2(_this), player = _assertThisInitialize.player, hls = _assertThisInitialize.hls;
14733
+ if (hls) {
14734
+ var _this$player$config, _this$player$config$h;
14735
+ var options = parseSwitchUrlArgs(args, _assertThisInitialized$2(_this));
14736
+ player.config.url = url;
14737
+ hls.switchURL(url, options).then(function() {
14738
+ return resolve(true);
14739
+ }).catch(reject);
14740
+ 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) {
14741
+ _this._keepPauseStatus();
14742
+ }
14743
+ } else {
14744
+ reject();
14745
+ }
14746
+ });
14747
+ });
15697
14748
  _defineProperty$3(_assertThisInitialized$2(_this), "_keepPauseStatus", function() {
15698
14749
  var paused = _this.player.paused;
15699
14750
  if (!paused)
@@ -15718,8 +14769,8 @@
15718
14769
  }, {
15719
14770
  key: "softDecode",
15720
14771
  get: function get() {
15721
- var _this$player, _this$player$config;
15722
- 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;
14772
+ var _this$player, _this$player$config2;
14773
+ 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;
15723
14774
  return !!mediaType && mediaType !== "video" && mediaType !== "audio";
15724
14775
  }
15725
14776
  }, {
@@ -15727,35 +14778,13 @@
15727
14778
  value: function beforePlayerInit() {
15728
14779
  var _this2 = this;
15729
14780
  var config = this.player.config;
15730
- var mediaElem = this.player.media || this.player.video;
15731
14781
  var hlsOpts = config.hls || {};
15732
14782
  if (!config.url && !config.__allowHlsEmptyUrl__ || !hlsOpts.preferMMS && MSE.isMMSOnly()) {
15733
14783
  return;
15734
14784
  }
15735
14785
  if (this.hls)
15736
14786
  this.hls.destroy();
15737
- var descriptor = Object.getOwnPropertyDescriptor(this.player, "switchURL");
15738
- if (!descriptor || descriptor.writable) {
15739
- this.player.switchURL = function(url, args) {
15740
- return new Promise(function(resolve, reject) {
15741
- var player = _this2.player, hls = _this2.hls;
15742
- if (hls) {
15743
- var _this2$player$config, _this2$player$config$;
15744
- var options = parseSwitchUrlArgs(args, _this2);
15745
- player.config.url = url;
15746
- hls.switchURL(url, options).then(function() {
15747
- return resolve(true);
15748
- }).catch(reject);
15749
- 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) {
15750
- _this2._keepPauseStatus();
15751
- }
15752
- } else {
15753
- reject();
15754
- }
15755
- });
15756
- };
15757
- }
15758
- var onSwitchUrl = this.player.switchURL;
14787
+ this.player.switchURL = this._onSwitchURL;
15759
14788
  this.player.handleSource = false;
15760
14789
  hlsOpts.innerDegrade = hlsOpts.innerDegrade || config.innerDegrade;
15761
14790
  if (hlsOpts.disconnectTime === null || hlsOpts.disconnectTime === void 0)
@@ -15763,7 +14792,7 @@
15763
14792
  this.hls = new Hls(_objectSpread2$2({
15764
14793
  softDecode: this.softDecode,
15765
14794
  isLive: config.isLive,
15766
- media: mediaElem,
14795
+ media: this.player.media || this.player.video,
15767
14796
  startTime: config.startTime,
15768
14797
  url: config.url
15769
14798
  }, hlsOpts));
@@ -15781,7 +14810,7 @@
15781
14810
  if (this.softDecode) {
15782
14811
  this.pluginExtension = new PluginExtension(_objectSpread2$2({
15783
14812
  isLive: config.isLive,
15784
- media: mediaElem
14813
+ media: this.player.video
15785
14814
  }, hlsOpts), this);
15786
14815
  this.player.forceDegradeToVideo = function() {
15787
14816
  var _this2$pluginExtensio;
@@ -15798,8 +14827,8 @@
15798
14827
  return (_this2$hls2 = _this2.hls) === null || _this2$hls2 === void 0 ? void 0 : _this2$hls2.replay();
15799
14828
  });
15800
14829
  }
15801
- this.on(URL_CHANGE, onSwitchUrl);
15802
14830
  this.on(SWITCH_SUBTITLE, this._onSwitchSubtitle);
14831
+ this.on(URL_CHANGE, this._onSwitchURL);
15803
14832
  this.on(DESTROY, this.destroy.bind(this));
15804
14833
  this._transError();
15805
14834
  this._transCoreEvent(EVENT.TTFB);
@@ -15809,7 +14838,6 @@
15809
14838
  this._transCoreEvent(EVENT.LOAD_RETRY);
15810
14839
  this._transCoreEvent(EVENT.SOURCEBUFFER_CREATED);
15811
14840
  this._transCoreEvent(EVENT.MEDIASOURCE_OPENED);
15812
- this._transCoreEvent(EVENT.APPEND_BUFFER);
15813
14841
  this._transCoreEvent(EVENT.REMOVE_BUFFER);
15814
14842
  this._transCoreEvent(EVENT.BUFFEREOS);
15815
14843
  this._transCoreEvent(EVENT.KEYFRAME);
@@ -15829,9 +14857,7 @@
15829
14857
  this._transCoreEvent(Event$1.SUBTITLE_PLAYLIST);
15830
14858
  this._transCoreEvent(Event$1.APPEND_COST);
15831
14859
  if (config.url) {
15832
- this.hls.load(config.url, {
15833
- reuseMse: true
15834
- }).catch(function(e) {
14860
+ this.hls.load(config.url, true).catch(function(e) {
15835
14861
  });
15836
14862
  }
15837
14863
  }