@volcengine/veplayer-plugin 2.4.0-rc.2 → 2.4.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1695,7 +1695,7 @@ var sniffer = {
1695
1695
  }
1696
1696
  }
1697
1697
  };
1698
- var version$3 = "3.0.17";
1698
+ var version$3 = "3.0.19-rc.0";
1699
1699
  var ERROR_MAP = {
1700
1700
  1: 5101,
1701
1701
  2: 5102,
@@ -2950,6 +2950,7 @@ var ERR$3 = {
2950
2950
  MSE_APPEND_BUFFER: "MSE_APPEND_BUFFER",
2951
2951
  MSE_OTHER: "MSE_OTHER",
2952
2952
  MSE_FULL: "MSE_FULL",
2953
+ MSE_CHANGE_TYPE: "MSE_CHANGE_TYPE",
2953
2954
  OPTION: "OPTION",
2954
2955
  DASH: "DASH",
2955
2956
  LICENSE: "LICENSE",
@@ -2992,6 +2993,7 @@ var ERR_CODE$3 = (_ERR_CODE$3 = {}, _defineProperty$f(_ERR_CODE$3, ERR$3.MANIFES
2992
2993
  MSE_OTHER: 5202,
2993
2994
  MSE_FULL: 5203,
2994
2995
  MSE_HIJACK: 5204,
2996
+ MSE_CHANGE_TYPE: 5205,
2995
2997
  EME_HIJACK: 5301
2996
2998
  }), _defineProperty$f(_ERR_CODE$3, ERR$3.DRM, {
2997
2999
  LICENSE: 7100,
@@ -3327,7 +3329,7 @@ var MSE$3 = /* @__PURE__ */ function() {
3327
3329
  queue.shift();
3328
3330
  }
3329
3331
  if (op) {
3330
- var _this2$_sourceBuffer$;
3332
+ var _this2$_sourceBuffer$, _op$context;
3331
3333
  var costtime = nowTime$6() - _this2._opst;
3332
3334
  _this2._logger.debug("UpdateEnd(".concat(type, "/").concat(op.opName, ")"), SafeJSON$1.stringify(getTimeRanges$1((_this2$_sourceBuffer$ = _this2._sourceBuffer[type]) === null || _this2$_sourceBuffer$ === void 0 ? void 0 : _this2$_sourceBuffer$.buffered)), costtime, op.context);
3333
3335
  op.promise.resolve({
@@ -3335,6 +3337,10 @@ var MSE$3 = /* @__PURE__ */ function() {
3335
3337
  context: op.context,
3336
3338
  costtime
3337
3339
  });
3340
+ var callback = (_op$context = op.context) === null || _op$context === void 0 ? void 0 : _op$context.callback;
3341
+ if (callback && typeof callback === "function") {
3342
+ callback(op.context);
3343
+ }
3338
3344
  _this2._startQueue(type);
3339
3345
  }
3340
3346
  }
@@ -3596,10 +3602,15 @@ var MSE$3 = /* @__PURE__ */ function() {
3596
3602
  var sb = this._sourceBuffer[type];
3597
3603
  if (!this.mediaSource || !sb || sb.mimeType === mimeType)
3598
3604
  return Promise.resolve();
3599
- if (typeof sb.changeType !== "function")
3600
- return Promise.reject();
3605
+ if (typeof sb.changeType !== "function") {
3606
+ return Promise.reject(new StreamingError$3(ERR$3.MEDIA, ERR$3.SUB_TYPES.MSE_CHANGE_TYPE, new Error("changeType is not a function")));
3607
+ }
3601
3608
  return this._enqueueOp(type, function() {
3602
- sb.changeType(mimeType);
3609
+ try {
3610
+ sb.changeType(mimeType);
3611
+ } catch (e) {
3612
+ throw new StreamingError$3(ERR$3.MEDIA, ERR$3.SUB_TYPES.MSE_CHANGE_TYPE, e);
3613
+ }
3603
3614
  sb.mimeType = mimeType;
3604
3615
  _this8._onSBUpdateEnd(type);
3605
3616
  }, "changeType", {
@@ -3849,11 +3860,14 @@ var MSE$3 = /* @__PURE__ */ function() {
3849
3860
  } catch (error) {
3850
3861
  if (error && error.message && error.message.indexOf("SourceBuffer is full") >= 0) {
3851
3862
  this._mseFullFlag[type] = true;
3863
+ if (op.context && _typeof$8(op.context) === "object") {
3864
+ op.context.isFull = true;
3865
+ }
3852
3866
  this._logger.error("[MSE error], context,", op.context, " ,name,", op.opName, ",err,SourceBuffer is full");
3853
3867
  op.promise.reject(new StreamingError$3(ERR$3.MEDIA, ERR$3.SUB_TYPES.MSE_FULL, error));
3854
3868
  } else {
3855
3869
  this._logger.error(error);
3856
- op.promise.reject(new StreamingError$3(ERR$3.MEDIA, ERR$3.SUB_TYPES.MSE_OTHER, error));
3870
+ op.promise.reject(error.constructor === StreamingError$3 ? error : new StreamingError$3(ERR$3.MEDIA, ERR$3.SUB_TYPES.MSE_OTHER, error));
3857
3871
  queue.shift();
3858
3872
  this._startQueue(type);
3859
3873
  }
@@ -5203,16 +5217,18 @@ var SeiService$1 = /* @__PURE__ */ function() {
5203
5217
  }]);
5204
5218
  return SeiService2;
5205
5219
  }();
5206
- var SKIP_SMALL_CHUNK = 1e3;
5207
- var MAX_CHUNK_SAVE_SIZE = 50;
5208
- var MAX_SEGMENT_SAVE_SIZE = 3;
5209
- var LONGTIME_NO_RECEIVE = 3e3;
5220
+ var SKIP_SMALL_CHUNK$1 = 1e3;
5221
+ var MAX_CHUNK_SAVE_SIZE$1 = 50;
5222
+ var MAX_SEGMENT_SAVE_SIZE$1 = 3;
5223
+ var LONGTIME_NO_RECEIVE$1 = 3e3;
5210
5224
  var BandwidthService$1 = /* @__PURE__ */ function() {
5211
5225
  function BandwidthService2(opts) {
5212
5226
  _classCallCheck$h(this, BandwidthService2);
5213
5227
  _defineProperty$f(this, "_chunkSpeed", 0);
5214
5228
  _defineProperty$f(this, "_chunkCache", []);
5215
5229
  _defineProperty$f(this, "_speeds", []);
5230
+ _defineProperty$f(this, "_totalSize", 0);
5231
+ _defineProperty$f(this, "_totalCost", 0);
5216
5232
  this._opts = opts || {};
5217
5233
  }
5218
5234
  _createClass$h(BandwidthService2, [{
@@ -5221,21 +5237,23 @@ var BandwidthService$1 = /* @__PURE__ */ function() {
5221
5237
  if (!totalByte || !ms)
5222
5238
  return;
5223
5239
  this._speeds.push(8e3 * totalByte / ms);
5224
- this._speeds = this._speeds.slice(-MAX_SEGMENT_SAVE_SIZE);
5240
+ this._speeds = this._speeds.slice(-MAX_SEGMENT_SAVE_SIZE$1);
5225
5241
  }
5226
5242
  }, {
5227
5243
  key: "addChunkRecord",
5228
5244
  value: function addChunkRecord(totalByte, ms) {
5229
5245
  var _this$_opts, _this$_opts2;
5230
- if (!totalByte || !ms || totalByte < (((_this$_opts = this._opts) === null || _this$_opts === void 0 ? void 0 : _this$_opts.skipChunkSize) || SKIP_SMALL_CHUNK))
5246
+ if (!totalByte || !ms || totalByte < (((_this$_opts = this._opts) === null || _this$_opts === void 0 ? void 0 : _this$_opts.skipChunkSize) || SKIP_SMALL_CHUNK$1))
5231
5247
  return;
5248
+ this._totalSize += totalByte;
5249
+ this._totalCost += ms;
5232
5250
  this._chunkSpeed = 8e3 * totalByte / ms;
5233
5251
  this._chunkCache.push({
5234
5252
  size: totalByte,
5235
5253
  duration: ms,
5236
5254
  timestamp: performance.now()
5237
5255
  });
5238
- var size = ((_this$_opts2 = this._opts) === null || _this$_opts2 === void 0 ? void 0 : _this$_opts2.chunkCountForSpeed) || MAX_CHUNK_SAVE_SIZE;
5256
+ var size = ((_this$_opts2 = this._opts) === null || _this$_opts2 === void 0 ? void 0 : _this$_opts2.chunkCountForSpeed) || MAX_CHUNK_SAVE_SIZE$1;
5239
5257
  if (this._chunkCache.length > size) {
5240
5258
  this._chunkCache = this._chunkCache.slice(-size);
5241
5259
  }
@@ -5253,7 +5271,7 @@ var BandwidthService$1 = /* @__PURE__ */ function() {
5253
5271
  }
5254
5272
  var lastSample = this._chunkCache[this._chunkCache.length - 1];
5255
5273
  var cost = performance.now() - lastSample.timestamp;
5256
- if (cost > (((_this$_opts3 = this._opts) === null || _this$_opts3 === void 0 ? void 0 : _this$_opts3.longtimeNoReceived) || LONGTIME_NO_RECEIVE)) {
5274
+ if (cost > (((_this$_opts3 = this._opts) === null || _this$_opts3 === void 0 ? void 0 : _this$_opts3.longtimeNoReceived) || LONGTIME_NO_RECEIVE$1)) {
5257
5275
  this._chunkCache.push({
5258
5276
  size: 0,
5259
5277
  duration: cost,
@@ -5278,11 +5296,23 @@ var BandwidthService$1 = /* @__PURE__ */ function() {
5278
5296
  }
5279
5297
  return this._chunkSpeed;
5280
5298
  }
5299
+ }, {
5300
+ key: "getTotalSize",
5301
+ value: function getTotalSize() {
5302
+ return this._totalSize;
5303
+ }
5304
+ }, {
5305
+ key: "getTotalCost",
5306
+ value: function getTotalCost() {
5307
+ return this._totalCost;
5308
+ }
5281
5309
  }, {
5282
5310
  key: "reset",
5283
5311
  value: function reset() {
5284
5312
  this._chunkCache = [];
5285
5313
  this._speeds = [];
5314
+ this._totalSize = 0;
5315
+ this._totalCost = 0;
5286
5316
  }
5287
5317
  }]);
5288
5318
  return BandwidthService2;
@@ -5411,13 +5441,15 @@ var MediaStatsService$1 = /* @__PURE__ */ function() {
5411
5441
  _createClass$h(MediaStatsService2, [{
5412
5442
  key: "getStats",
5413
5443
  value: function getStats2() {
5414
- var _this$_core, _this$_core2, _this$_core2$speedInf, _this$_core3, _this$_core3$speedInf, _this$_core4, _this$_core4$bufferIn;
5444
+ var _this$_core, _this$_core2, _this$_core2$speedInf, _this$_core3, _this$_core3$speedInf, _this$_core4, _this$_core4$speedInf, _this$_core5, _this$_core5$speedInf, _this$_core6, _this$_core6$bufferIn;
5415
5445
  var _ref2 = ((_this$_core = this._core) === null || _this$_core === void 0 ? void 0 : _this$_core.media) || {}, _ref2$currentTime = _ref2.currentTime, currentTime = _ref2$currentTime === void 0 ? 0 : _ref2$currentTime, _ref2$decodeFps = _ref2.decodeFps, decodeFps = _ref2$decodeFps === void 0 ? 0 : _ref2$decodeFps;
5416
5446
  return _objectSpread2$8(_objectSpread2$8({}, this._stats.getStats()), {}, {
5417
5447
  downloadSpeed: ((_this$_core2 = this._core) === null || _this$_core2 === void 0 ? void 0 : (_this$_core2$speedInf = _this$_core2.speedInfo) === null || _this$_core2$speedInf === void 0 ? void 0 : _this$_core2$speedInf.call(_this$_core2).speed) || 0,
5418
5448
  avgSpeed: ((_this$_core3 = this._core) === null || _this$_core3 === void 0 ? void 0 : (_this$_core3$speedInf = _this$_core3.speedInfo) === null || _this$_core3$speedInf === void 0 ? void 0 : _this$_core3$speedInf.call(_this$_core3).avgSpeed) || 0,
5449
+ totalReceivedByte: ((_this$_core4 = this._core) === null || _this$_core4 === void 0 ? void 0 : (_this$_core4$speedInf = _this$_core4.speedInfo) === null || _this$_core4$speedInf === void 0 ? void 0 : _this$_core4$speedInf.call(_this$_core4).totalSize) || 0,
5450
+ totalReceivedCost: ((_this$_core5 = this._core) === null || _this$_core5 === void 0 ? void 0 : (_this$_core5$speedInf = _this$_core5.speedInfo) === null || _this$_core5$speedInf === void 0 ? void 0 : _this$_core5$speedInf.call(_this$_core5).totalCost) || 0,
5419
5451
  currentTime,
5420
- bufferEnd: ((_this$_core4 = this._core) === null || _this$_core4 === void 0 ? void 0 : (_this$_core4$bufferIn = _this$_core4.bufferInfo()) === null || _this$_core4$bufferIn === void 0 ? void 0 : _this$_core4$bufferIn.remaining) || 0,
5452
+ bufferEnd: ((_this$_core6 = this._core) === null || _this$_core6 === void 0 ? void 0 : (_this$_core6$bufferIn = _this$_core6.bufferInfo()) === null || _this$_core6$bufferIn === void 0 ? void 0 : _this$_core6$bufferIn.remaining) || 0,
5421
5453
  decodeFps
5422
5454
  });
5423
5455
  }
@@ -12278,7 +12310,7 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
12278
12310
  _createClass$j(Flv2, [{
12279
12311
  key: "version",
12280
12312
  get: function get3() {
12281
- return "3.0.18-alpha.3";
12313
+ return "3.0.19-rc.0";
12282
12314
  }
12283
12315
  }, {
12284
12316
  key: "isLive",
@@ -12312,7 +12344,9 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
12312
12344
  value: function speedInfo() {
12313
12345
  return {
12314
12346
  speed: this._bandwidthService.getLatestSpeed(),
12315
- avgSpeed: this._bandwidthService.getAvgSpeed()
12347
+ avgSpeed: this._bandwidthService.getAvgSpeed(),
12348
+ totalSize: this._bandwidthService.getTotalSize(),
12349
+ totalCost: this._bandwidthService.getTotalCost()
12316
12350
  };
12317
12351
  }
12318
12352
  }, {
@@ -12602,7 +12636,7 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
12602
12636
  _context9.prev = 17;
12603
12637
  _context9.t0 = _context9["catch"](12);
12604
12638
  this._loading = false;
12605
- return _context9.abrupt("return", this._emitError(StreamingError$3.network(_context9.t0)));
12639
+ return _context9.abrupt("return", this._emitError(StreamingError$3.network(_context9.t0), false));
12606
12640
  case 21:
12607
12641
  case "end":
12608
12642
  return _context9.stop();
@@ -32546,6 +32580,7 @@ var ERR$1 = {
32546
32580
  MSE_APPEND_BUFFER: "MSE_APPEND_BUFFER",
32547
32581
  MSE_OTHER: "MSE_OTHER",
32548
32582
  MSE_FULL: "MSE_FULL",
32583
+ MSE_CHANGE_TYPE: "MSE_CHANGE_TYPE",
32549
32584
  OPTION: "OPTION",
32550
32585
  DASH: "DASH",
32551
32586
  LICENSE: "LICENSE",
@@ -32588,6 +32623,7 @@ var ERR_CODE$1 = (_ERR_CODE$1 = {}, _defineProperty$9(_ERR_CODE$1, ERR$1.MANIFES
32588
32623
  MSE_OTHER: 5202,
32589
32624
  MSE_FULL: 5203,
32590
32625
  MSE_HIJACK: 5204,
32626
+ MSE_CHANGE_TYPE: 5205,
32591
32627
  EME_HIJACK: 5301
32592
32628
  }), _defineProperty$9(_ERR_CODE$1, ERR$1.DRM, {
32593
32629
  LICENSE: 7100,
@@ -32923,7 +32959,7 @@ var MSE$2 = /* @__PURE__ */ function() {
32923
32959
  queue.shift();
32924
32960
  }
32925
32961
  if (op) {
32926
- var _this2$_sourceBuffer$;
32962
+ var _this2$_sourceBuffer$, _op$context;
32927
32963
  var costtime = nowTime$3() - _this2._opst;
32928
32964
  _this2._logger.debug("UpdateEnd(".concat(type, "/").concat(op.opName, ")"), SafeJSON.stringify(getTimeRanges((_this2$_sourceBuffer$ = _this2._sourceBuffer[type]) === null || _this2$_sourceBuffer$ === void 0 ? void 0 : _this2$_sourceBuffer$.buffered)), costtime, op.context);
32929
32965
  op.promise.resolve({
@@ -32931,6 +32967,10 @@ var MSE$2 = /* @__PURE__ */ function() {
32931
32967
  context: op.context,
32932
32968
  costtime
32933
32969
  });
32970
+ var callback = (_op$context = op.context) === null || _op$context === void 0 ? void 0 : _op$context.callback;
32971
+ if (callback && typeof callback === "function") {
32972
+ callback(op.context);
32973
+ }
32934
32974
  _this2._startQueue(type);
32935
32975
  }
32936
32976
  }
@@ -33192,10 +33232,15 @@ var MSE$2 = /* @__PURE__ */ function() {
33192
33232
  var sb = this._sourceBuffer[type];
33193
33233
  if (!this.mediaSource || !sb || sb.mimeType === mimeType)
33194
33234
  return Promise.resolve();
33195
- if (typeof sb.changeType !== "function")
33196
- return Promise.reject();
33235
+ if (typeof sb.changeType !== "function") {
33236
+ return Promise.reject(new StreamingError$1(ERR$1.MEDIA, ERR$1.SUB_TYPES.MSE_CHANGE_TYPE, new Error("changeType is not a function")));
33237
+ }
33197
33238
  return this._enqueueOp(type, function() {
33198
- sb.changeType(mimeType);
33239
+ try {
33240
+ sb.changeType(mimeType);
33241
+ } catch (e) {
33242
+ throw new StreamingError$1(ERR$1.MEDIA, ERR$1.SUB_TYPES.MSE_CHANGE_TYPE, e);
33243
+ }
33199
33244
  sb.mimeType = mimeType;
33200
33245
  _this8._onSBUpdateEnd(type);
33201
33246
  }, "changeType", {
@@ -33445,11 +33490,14 @@ var MSE$2 = /* @__PURE__ */ function() {
33445
33490
  } catch (error) {
33446
33491
  if (error && error.message && error.message.indexOf("SourceBuffer is full") >= 0) {
33447
33492
  this._mseFullFlag[type] = true;
33493
+ if (op.context && _typeof$4(op.context) === "object") {
33494
+ op.context.isFull = true;
33495
+ }
33448
33496
  this._logger.error("[MSE error], context,", op.context, " ,name,", op.opName, ",err,SourceBuffer is full");
33449
33497
  op.promise.reject(new StreamingError$1(ERR$1.MEDIA, ERR$1.SUB_TYPES.MSE_FULL, error));
33450
33498
  } else {
33451
33499
  this._logger.error(error);
33452
- op.promise.reject(new StreamingError$1(ERR$1.MEDIA, ERR$1.SUB_TYPES.MSE_OTHER, error));
33500
+ op.promise.reject(error.constructor === StreamingError$1 ? error : new StreamingError$1(ERR$1.MEDIA, ERR$1.SUB_TYPES.MSE_OTHER, error));
33453
33501
  queue.shift();
33454
33502
  this._startQueue(type);
33455
33503
  }
@@ -34799,11 +34847,19 @@ var SeiService = /* @__PURE__ */ function() {
34799
34847
  }]);
34800
34848
  return SeiService2;
34801
34849
  }();
34850
+ var SKIP_SMALL_CHUNK = 1e3;
34851
+ var MAX_CHUNK_SAVE_SIZE = 50;
34852
+ var MAX_SEGMENT_SAVE_SIZE = 3;
34853
+ var LONGTIME_NO_RECEIVE = 3e3;
34802
34854
  var BandwidthService = /* @__PURE__ */ function() {
34803
- function BandwidthService2() {
34855
+ function BandwidthService2(opts) {
34804
34856
  _classCallCheck$b(this, BandwidthService2);
34805
- _defineProperty$9(this, "_chunkSpeeds", []);
34857
+ _defineProperty$9(this, "_chunkSpeed", 0);
34858
+ _defineProperty$9(this, "_chunkCache", []);
34806
34859
  _defineProperty$9(this, "_speeds", []);
34860
+ _defineProperty$9(this, "_totalSize", 0);
34861
+ _defineProperty$9(this, "_totalCost", 0);
34862
+ this._opts = opts || {};
34807
34863
  }
34808
34864
  _createClass$b(BandwidthService2, [{
34809
34865
  key: "addRecord",
@@ -34811,45 +34867,82 @@ var BandwidthService = /* @__PURE__ */ function() {
34811
34867
  if (!totalByte || !ms)
34812
34868
  return;
34813
34869
  this._speeds.push(8e3 * totalByte / ms);
34814
- this._speeds = this._speeds.slice(-3);
34870
+ this._speeds = this._speeds.slice(-MAX_SEGMENT_SAVE_SIZE);
34815
34871
  }
34816
34872
  }, {
34817
34873
  key: "addChunkRecord",
34818
34874
  value: function addChunkRecord(totalByte, ms) {
34819
- if (!totalByte || !ms)
34875
+ var _this$_opts, _this$_opts2;
34876
+ if (!totalByte || !ms || totalByte < (((_this$_opts = this._opts) === null || _this$_opts === void 0 ? void 0 : _this$_opts.skipChunkSize) || SKIP_SMALL_CHUNK))
34820
34877
  return;
34821
- this._chunkSpeeds.push(8e3 * totalByte / ms);
34822
- this._chunkSpeeds = this._chunkSpeeds.slice(-100);
34878
+ this._totalSize += totalByte;
34879
+ this._totalCost += ms;
34880
+ this._chunkSpeed = 8e3 * totalByte / ms;
34881
+ this._chunkCache.push({
34882
+ size: totalByte,
34883
+ duration: ms,
34884
+ timestamp: performance.now()
34885
+ });
34886
+ var size = ((_this$_opts2 = this._opts) === null || _this$_opts2 === void 0 ? void 0 : _this$_opts2.chunkCountForSpeed) || MAX_CHUNK_SAVE_SIZE;
34887
+ if (this._chunkCache.length > size) {
34888
+ this._chunkCache = this._chunkCache.slice(-size);
34889
+ }
34823
34890
  }
34824
34891
  }, {
34825
34892
  key: "getAvgSpeed",
34826
34893
  value: function getAvgSpeed() {
34827
- if (!this._chunkSpeeds.length && !this._speeds.length)
34894
+ var _this$_opts3;
34895
+ if (!this._chunkCache.length && !this._speeds.length)
34828
34896
  return 0;
34829
34897
  if (this._speeds.length) {
34830
34898
  return this._speeds.reduce(function(a, c) {
34831
34899
  return a += c;
34832
34900
  }) / this._speeds.length;
34833
34901
  }
34834
- return this._chunkSpeeds.reduce(function(a, c) {
34835
- return a += c;
34836
- }) / this._chunkSpeeds.length;
34902
+ var lastSample = this._chunkCache[this._chunkCache.length - 1];
34903
+ var cost = performance.now() - lastSample.timestamp;
34904
+ if (cost > (((_this$_opts3 = this._opts) === null || _this$_opts3 === void 0 ? void 0 : _this$_opts3.longtimeNoReceived) || LONGTIME_NO_RECEIVE)) {
34905
+ this._chunkCache.push({
34906
+ size: 0,
34907
+ duration: cost,
34908
+ timestamp: performance.now()
34909
+ });
34910
+ }
34911
+ var totalSize = this._chunkCache.reduce(function(a, c) {
34912
+ return a += c.size;
34913
+ }, 0);
34914
+ var totalDuration = this._chunkCache.reduce(function(a, c) {
34915
+ return a += c.duration;
34916
+ }, 0);
34917
+ return 8e3 * totalSize / totalDuration;
34837
34918
  }
34838
34919
  }, {
34839
34920
  key: "getLatestSpeed",
34840
34921
  value: function getLatestSpeed() {
34841
- if (!this._chunkSpeeds.length && !this._speeds.length)
34922
+ if (!this._chunkCache.length && !this._speeds.length)
34842
34923
  return 0;
34843
34924
  if (this._speeds.length) {
34844
34925
  return this._speeds[this._speeds.length - 1];
34845
34926
  }
34846
- return this._chunkSpeeds[this._chunkSpeeds.length - 1];
34927
+ return this._chunkSpeed;
34928
+ }
34929
+ }, {
34930
+ key: "getTotalSize",
34931
+ value: function getTotalSize() {
34932
+ return this._totalSize;
34933
+ }
34934
+ }, {
34935
+ key: "getTotalCost",
34936
+ value: function getTotalCost() {
34937
+ return this._totalCost;
34847
34938
  }
34848
34939
  }, {
34849
34940
  key: "reset",
34850
34941
  value: function reset() {
34851
- this._chunkSpeeds = [];
34942
+ this._chunkCache = [];
34852
34943
  this._speeds = [];
34944
+ this._totalSize = 0;
34945
+ this._totalCost = 0;
34853
34946
  }
34854
34947
  }]);
34855
34948
  return BandwidthService2;
@@ -34978,13 +35071,15 @@ var MediaStatsService = /* @__PURE__ */ function() {
34978
35071
  _createClass$b(MediaStatsService2, [{
34979
35072
  key: "getStats",
34980
35073
  value: function getStats2() {
34981
- var _this$_core, _this$_core2, _this$_core2$speedInf, _this$_core3, _this$_core3$speedInf, _this$_core4, _this$_core4$bufferIn;
35074
+ var _this$_core, _this$_core2, _this$_core2$speedInf, _this$_core3, _this$_core3$speedInf, _this$_core4, _this$_core4$speedInf, _this$_core5, _this$_core5$speedInf, _this$_core6, _this$_core6$bufferIn;
34982
35075
  var _ref2 = ((_this$_core = this._core) === null || _this$_core === void 0 ? void 0 : _this$_core.media) || {}, _ref2$currentTime = _ref2.currentTime, currentTime = _ref2$currentTime === void 0 ? 0 : _ref2$currentTime, _ref2$decodeFps = _ref2.decodeFps, decodeFps = _ref2$decodeFps === void 0 ? 0 : _ref2$decodeFps;
34983
35076
  return _objectSpread2$4(_objectSpread2$4({}, this._stats.getStats()), {}, {
34984
35077
  downloadSpeed: ((_this$_core2 = this._core) === null || _this$_core2 === void 0 ? void 0 : (_this$_core2$speedInf = _this$_core2.speedInfo) === null || _this$_core2$speedInf === void 0 ? void 0 : _this$_core2$speedInf.call(_this$_core2).speed) || 0,
34985
35078
  avgSpeed: ((_this$_core3 = this._core) === null || _this$_core3 === void 0 ? void 0 : (_this$_core3$speedInf = _this$_core3.speedInfo) === null || _this$_core3$speedInf === void 0 ? void 0 : _this$_core3$speedInf.call(_this$_core3).avgSpeed) || 0,
35079
+ totalReceivedByte: ((_this$_core4 = this._core) === null || _this$_core4 === void 0 ? void 0 : (_this$_core4$speedInf = _this$_core4.speedInfo) === null || _this$_core4$speedInf === void 0 ? void 0 : _this$_core4$speedInf.call(_this$_core4).totalSize) || 0,
35080
+ totalReceivedCost: ((_this$_core5 = this._core) === null || _this$_core5 === void 0 ? void 0 : (_this$_core5$speedInf = _this$_core5.speedInfo) === null || _this$_core5$speedInf === void 0 ? void 0 : _this$_core5$speedInf.call(_this$_core5).totalCost) || 0,
34986
35081
  currentTime,
34987
- bufferEnd: ((_this$_core4 = this._core) === null || _this$_core4 === void 0 ? void 0 : (_this$_core4$bufferIn = _this$_core4.bufferInfo()) === null || _this$_core4$bufferIn === void 0 ? void 0 : _this$_core4$bufferIn.remaining) || 0,
35082
+ bufferEnd: ((_this$_core6 = this._core) === null || _this$_core6 === void 0 ? void 0 : (_this$_core6$bufferIn = _this$_core6.bufferInfo()) === null || _this$_core6$bufferIn === void 0 ? void 0 : _this$_core6$bufferIn.remaining) || 0,
34988
35083
  decodeFps
34989
35084
  });
34990
35085
  }
@@ -40860,7 +40955,9 @@ var BufferService = /* @__PURE__ */ function() {
40860
40955
  mse = this._mse;
40861
40956
  _p = [];
40862
40957
  if (needInit && !isFirstAppend) {
40863
- this._handleCodecChange(video, audio);
40958
+ this._handleCodecChange(video, audio).forEach(function(task2) {
40959
+ return _p.push(task2);
40960
+ });
40864
40961
  }
40865
40962
  if (video) {
40866
40963
  videoData = video.data, videoRest = _objectWithoutProperties$3(video, _excluded$2);
@@ -41133,6 +41230,7 @@ var BufferService = /* @__PURE__ */ function() {
41133
41230
  }, {
41134
41231
  key: "_handleCodecChange",
41135
41232
  value: function _handleCodecChange(video, audio) {
41233
+ var tasks = [];
41136
41234
  var mse = this._mse;
41137
41235
  var codecList = [{
41138
41236
  type: MSE$2.VIDEO,
@@ -41149,10 +41247,11 @@ var BufferService = /* @__PURE__ */ function() {
41149
41247
  if (sourceBuffer) {
41150
41248
  var codec = codecs.split(",")[0];
41151
41249
  if (!new RegExp(codec, "ig").test(sourceBuffer.mimeType)) {
41152
- mse.changeType(type, "".concat(type, "/mp4;codecs=").concat(codecs));
41250
+ tasks.push(mse.changeType(type, "".concat(type, "/mp4;codecs=").concat(codecs)));
41153
41251
  }
41154
41252
  }
41155
41253
  });
41254
+ return tasks;
41156
41255
  }
41157
41256
  }, {
41158
41257
  key: "seamlessSwitch",
@@ -41211,10 +41310,21 @@ var MediaType = {
41211
41310
  };
41212
41311
  var KeySystems = {
41213
41312
  CLEAR_KEY: "org.w3.clearkey",
41214
- FAIRPLAY: "com.apple.streamingkeydelivery",
41215
- WIDEVINE: "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",
41216
- PLAYREADY: "com.microsoft.playready"
41217
- };
41313
+ FAIRPLAY: ["urn:uuid:94ce86fb-07ff-4f43-adb8-93d2fa968ca2", "com.apple.streamingkeydelivery"],
41314
+ WIDEVINE: ["urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed", "com.widevine.alpha", "com.widevine"],
41315
+ PLAYREADY: ["urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95", "com.microsoft.playready"]
41316
+ };
41317
+ function flatArray(arr) {
41318
+ var ret = [];
41319
+ for (var i = 0; i < arr.length; i++) {
41320
+ if (Array.isArray(arr[i])) {
41321
+ ret = ret.concat(flatArray(arr[i]));
41322
+ } else {
41323
+ ret.push(arr[i]);
41324
+ }
41325
+ }
41326
+ return ret;
41327
+ }
41218
41328
  var MediaStream$1 = /* @__PURE__ */ _createClass$c(function MediaStream2() {
41219
41329
  _classCallCheck$c(this, MediaStream2);
41220
41330
  _defineProperty$a(this, "id", 0);
@@ -41391,7 +41501,7 @@ var MediaSegmentKey = /* @__PURE__ */ function() {
41391
41501
  }, {
41392
41502
  key: "isValidKeySystem",
41393
41503
  value: function isValidKeySystem() {
41394
- var isKeyFormatValid = [KeySystems.CLEAR_KEY, KeySystems.FAIRPLAY, KeySystems.WIDEVINE, KeySystems.PLAYREADY].indexOf(this.keyFormat) > -1;
41504
+ var isKeyFormatValid = flatArray([KeySystems.CLEAR_KEY, KeySystems.FAIRPLAY, KeySystems.WIDEVINE, KeySystems.PLAYREADY]).indexOf(this.keyFormat) > -1;
41395
41505
  if (!isKeyFormatValid) {
41396
41506
  return false;
41397
41507
  }
@@ -44176,7 +44286,7 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
44176
44286
  }]);
44177
44287
  return Hls2;
44178
44288
  }(EventEmitter$1);
44179
- _defineProperty$a(Hls, "version", "3.0.17");
44289
+ _defineProperty$a(Hls, "version", "3.0.19-rc.0");
44180
44290
  try {
44181
44291
  if (localStorage.getItem("xgd")) {
44182
44292
  Hls.enableLogger();