@byteplus/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.
@@ -1538,7 +1538,7 @@ util.getCurrentTimeByOffset = function(offsetTime, segments) {
1538
1538
  }
1539
1539
  return offsetTime;
1540
1540
  };
1541
- var version = "3.0.17";
1541
+ var version = "3.0.19-rc.0";
1542
1542
  var ERROR_MAP = {
1543
1543
  1: 5101,
1544
1544
  2: 5102,
@@ -2786,6 +2786,7 @@ var ERR = {
2786
2786
  MSE_APPEND_BUFFER: "MSE_APPEND_BUFFER",
2787
2787
  MSE_OTHER: "MSE_OTHER",
2788
2788
  MSE_FULL: "MSE_FULL",
2789
+ MSE_CHANGE_TYPE: "MSE_CHANGE_TYPE",
2789
2790
  OPTION: "OPTION",
2790
2791
  DASH: "DASH",
2791
2792
  LICENSE: "LICENSE",
@@ -2828,6 +2829,7 @@ var ERR_CODE = (_ERR_CODE = {}, _defineProperty$1(_ERR_CODE, ERR.MANIFEST, {
2828
2829
  MSE_OTHER: 5202,
2829
2830
  MSE_FULL: 5203,
2830
2831
  MSE_HIJACK: 5204,
2832
+ MSE_CHANGE_TYPE: 5205,
2831
2833
  EME_HIJACK: 5301
2832
2834
  }), _defineProperty$1(_ERR_CODE, ERR.DRM, {
2833
2835
  LICENSE: 7100,
@@ -3163,7 +3165,7 @@ var MSE = /* @__PURE__ */ function() {
3163
3165
  queue.shift();
3164
3166
  }
3165
3167
  if (op) {
3166
- var _this2$_sourceBuffer$;
3168
+ var _this2$_sourceBuffer$, _op$context;
3167
3169
  var costtime = nowTime() - _this2._opst;
3168
3170
  _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);
3169
3171
  op.promise.resolve({
@@ -3171,6 +3173,10 @@ var MSE = /* @__PURE__ */ function() {
3171
3173
  context: op.context,
3172
3174
  costtime
3173
3175
  });
3176
+ var callback = (_op$context = op.context) === null || _op$context === void 0 ? void 0 : _op$context.callback;
3177
+ if (callback && typeof callback === "function") {
3178
+ callback(op.context);
3179
+ }
3174
3180
  _this2._startQueue(type);
3175
3181
  }
3176
3182
  }
@@ -3432,10 +3438,15 @@ var MSE = /* @__PURE__ */ function() {
3432
3438
  var sb = this._sourceBuffer[type];
3433
3439
  if (!this.mediaSource || !sb || sb.mimeType === mimeType)
3434
3440
  return Promise.resolve();
3435
- if (typeof sb.changeType !== "function")
3436
- return Promise.reject();
3441
+ if (typeof sb.changeType !== "function") {
3442
+ return Promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_CHANGE_TYPE, new Error("changeType is not a function")));
3443
+ }
3437
3444
  return this._enqueueOp(type, function() {
3438
- sb.changeType(mimeType);
3445
+ try {
3446
+ sb.changeType(mimeType);
3447
+ } catch (e) {
3448
+ throw new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_CHANGE_TYPE, e);
3449
+ }
3439
3450
  sb.mimeType = mimeType;
3440
3451
  _this8._onSBUpdateEnd(type);
3441
3452
  }, "changeType", {
@@ -3685,11 +3696,14 @@ var MSE = /* @__PURE__ */ function() {
3685
3696
  } catch (error) {
3686
3697
  if (error && error.message && error.message.indexOf("SourceBuffer is full") >= 0) {
3687
3698
  this._mseFullFlag[type] = true;
3699
+ if (op.context && _typeof(op.context) === "object") {
3700
+ op.context.isFull = true;
3701
+ }
3688
3702
  this._logger.error("[MSE error], context,", op.context, " ,name,", op.opName, ",err,SourceBuffer is full");
3689
3703
  op.promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_FULL, error));
3690
3704
  } else {
3691
3705
  this._logger.error(error);
3692
- op.promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_OTHER, error));
3706
+ op.promise.reject(error.constructor === StreamingError ? error : new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_OTHER, error));
3693
3707
  queue.shift();
3694
3708
  this._startQueue(type);
3695
3709
  }
@@ -5049,6 +5063,8 @@ var BandwidthService = /* @__PURE__ */ function() {
5049
5063
  _defineProperty$1(this, "_chunkSpeed", 0);
5050
5064
  _defineProperty$1(this, "_chunkCache", []);
5051
5065
  _defineProperty$1(this, "_speeds", []);
5066
+ _defineProperty$1(this, "_totalSize", 0);
5067
+ _defineProperty$1(this, "_totalCost", 0);
5052
5068
  this._opts = opts || {};
5053
5069
  }
5054
5070
  _createClass$2(BandwidthService2, [{
@@ -5065,6 +5081,8 @@ var BandwidthService = /* @__PURE__ */ function() {
5065
5081
  var _this$_opts, _this$_opts2;
5066
5082
  if (!totalByte || !ms || totalByte < (((_this$_opts = this._opts) === null || _this$_opts === void 0 ? void 0 : _this$_opts.skipChunkSize) || SKIP_SMALL_CHUNK))
5067
5083
  return;
5084
+ this._totalSize += totalByte;
5085
+ this._totalCost += ms;
5068
5086
  this._chunkSpeed = 8e3 * totalByte / ms;
5069
5087
  this._chunkCache.push({
5070
5088
  size: totalByte,
@@ -5114,11 +5132,23 @@ var BandwidthService = /* @__PURE__ */ function() {
5114
5132
  }
5115
5133
  return this._chunkSpeed;
5116
5134
  }
5135
+ }, {
5136
+ key: "getTotalSize",
5137
+ value: function getTotalSize() {
5138
+ return this._totalSize;
5139
+ }
5140
+ }, {
5141
+ key: "getTotalCost",
5142
+ value: function getTotalCost() {
5143
+ return this._totalCost;
5144
+ }
5117
5145
  }, {
5118
5146
  key: "reset",
5119
5147
  value: function reset() {
5120
5148
  this._chunkCache = [];
5121
5149
  this._speeds = [];
5150
+ this._totalSize = 0;
5151
+ this._totalCost = 0;
5122
5152
  }
5123
5153
  }]);
5124
5154
  return BandwidthService2;
@@ -5247,13 +5277,15 @@ var MediaStatsService = /* @__PURE__ */ function() {
5247
5277
  _createClass$2(MediaStatsService2, [{
5248
5278
  key: "getStats",
5249
5279
  value: function getStats() {
5250
- var _this$_core, _this$_core2, _this$_core2$speedInf, _this$_core3, _this$_core3$speedInf, _this$_core4, _this$_core4$bufferIn;
5280
+ 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;
5251
5281
  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;
5252
5282
  return _objectSpread2(_objectSpread2({}, this._stats.getStats()), {}, {
5253
5283
  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,
5254
5284
  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,
5285
+ 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,
5286
+ 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,
5255
5287
  currentTime,
5256
- 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,
5288
+ 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,
5257
5289
  decodeFps
5258
5290
  });
5259
5291
  }
@@ -10447,7 +10479,7 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10447
10479
  _createClass$4(Flv2, [{
10448
10480
  key: "version",
10449
10481
  get: function get() {
10450
- return "3.0.18-alpha.3";
10482
+ return "3.0.19-rc.0";
10451
10483
  }
10452
10484
  }, {
10453
10485
  key: "isLive",
@@ -10481,7 +10513,9 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10481
10513
  value: function speedInfo() {
10482
10514
  return {
10483
10515
  speed: this._bandwidthService.getLatestSpeed(),
10484
- avgSpeed: this._bandwidthService.getAvgSpeed()
10516
+ avgSpeed: this._bandwidthService.getAvgSpeed(),
10517
+ totalSize: this._bandwidthService.getTotalSize(),
10518
+ totalCost: this._bandwidthService.getTotalCost()
10485
10519
  };
10486
10520
  }
10487
10521
  }, {
@@ -10771,7 +10805,7 @@ var Flv = /* @__PURE__ */ function(_EventEmitter) {
10771
10805
  _context9.prev = 17;
10772
10806
  _context9.t0 = _context9["catch"](12);
10773
10807
  this._loading = false;
10774
- return _context9.abrupt("return", this._emitError(StreamingError.network(_context9.t0)));
10808
+ return _context9.abrupt("return", this._emitError(StreamingError.network(_context9.t0), false));
10775
10809
  case 21:
10776
10810
  case "end":
10777
10811
  return _context9.stop();