@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byteplus/veplayer-plugin",
3
- "version": "2.4.0-rc.2",
3
+ "version": "2.4.0-rc.4",
4
4
  "main": "./umd/index.production.js",
5
5
  "module": "./esm/index.production.js",
6
6
  "browser": "./umd/index.production.js",
@@ -1542,7 +1542,7 @@
1542
1542
  }
1543
1543
  return offsetTime;
1544
1544
  };
1545
- var version = "3.0.17";
1545
+ var version = "3.0.19-rc.0";
1546
1546
  var ERROR_MAP = {
1547
1547
  1: 5101,
1548
1548
  2: 5102,
@@ -2790,6 +2790,7 @@
2790
2790
  MSE_APPEND_BUFFER: "MSE_APPEND_BUFFER",
2791
2791
  MSE_OTHER: "MSE_OTHER",
2792
2792
  MSE_FULL: "MSE_FULL",
2793
+ MSE_CHANGE_TYPE: "MSE_CHANGE_TYPE",
2793
2794
  OPTION: "OPTION",
2794
2795
  DASH: "DASH",
2795
2796
  LICENSE: "LICENSE",
@@ -2832,6 +2833,7 @@
2832
2833
  MSE_OTHER: 5202,
2833
2834
  MSE_FULL: 5203,
2834
2835
  MSE_HIJACK: 5204,
2836
+ MSE_CHANGE_TYPE: 5205,
2835
2837
  EME_HIJACK: 5301
2836
2838
  }), _defineProperty$1(_ERR_CODE, ERR.DRM, {
2837
2839
  LICENSE: 7100,
@@ -3167,7 +3169,7 @@
3167
3169
  queue.shift();
3168
3170
  }
3169
3171
  if (op) {
3170
- var _this2$_sourceBuffer$;
3172
+ var _this2$_sourceBuffer$, _op$context;
3171
3173
  var costtime = nowTime() - _this2._opst;
3172
3174
  _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);
3173
3175
  op.promise.resolve({
@@ -3175,6 +3177,10 @@
3175
3177
  context: op.context,
3176
3178
  costtime
3177
3179
  });
3180
+ var callback = (_op$context = op.context) === null || _op$context === void 0 ? void 0 : _op$context.callback;
3181
+ if (callback && typeof callback === "function") {
3182
+ callback(op.context);
3183
+ }
3178
3184
  _this2._startQueue(type);
3179
3185
  }
3180
3186
  }
@@ -3436,10 +3442,15 @@
3436
3442
  var sb = this._sourceBuffer[type];
3437
3443
  if (!this.mediaSource || !sb || sb.mimeType === mimeType)
3438
3444
  return Promise.resolve();
3439
- if (typeof sb.changeType !== "function")
3440
- return Promise.reject();
3445
+ if (typeof sb.changeType !== "function") {
3446
+ return Promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_CHANGE_TYPE, new Error("changeType is not a function")));
3447
+ }
3441
3448
  return this._enqueueOp(type, function() {
3442
- sb.changeType(mimeType);
3449
+ try {
3450
+ sb.changeType(mimeType);
3451
+ } catch (e) {
3452
+ throw new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_CHANGE_TYPE, e);
3453
+ }
3443
3454
  sb.mimeType = mimeType;
3444
3455
  _this8._onSBUpdateEnd(type);
3445
3456
  }, "changeType", {
@@ -3689,11 +3700,14 @@
3689
3700
  } catch (error) {
3690
3701
  if (error && error.message && error.message.indexOf("SourceBuffer is full") >= 0) {
3691
3702
  this._mseFullFlag[type] = true;
3703
+ if (op.context && _typeof(op.context) === "object") {
3704
+ op.context.isFull = true;
3705
+ }
3692
3706
  this._logger.error("[MSE error], context,", op.context, " ,name,", op.opName, ",err,SourceBuffer is full");
3693
3707
  op.promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_FULL, error));
3694
3708
  } else {
3695
3709
  this._logger.error(error);
3696
- op.promise.reject(new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_OTHER, error));
3710
+ op.promise.reject(error.constructor === StreamingError ? error : new StreamingError(ERR.MEDIA, ERR.SUB_TYPES.MSE_OTHER, error));
3697
3711
  queue.shift();
3698
3712
  this._startQueue(type);
3699
3713
  }
@@ -5053,6 +5067,8 @@
5053
5067
  _defineProperty$1(this, "_chunkSpeed", 0);
5054
5068
  _defineProperty$1(this, "_chunkCache", []);
5055
5069
  _defineProperty$1(this, "_speeds", []);
5070
+ _defineProperty$1(this, "_totalSize", 0);
5071
+ _defineProperty$1(this, "_totalCost", 0);
5056
5072
  this._opts = opts || {};
5057
5073
  }
5058
5074
  _createClass$2(BandwidthService2, [{
@@ -5069,6 +5085,8 @@
5069
5085
  var _this$_opts, _this$_opts2;
5070
5086
  if (!totalByte || !ms || totalByte < (((_this$_opts = this._opts) === null || _this$_opts === void 0 ? void 0 : _this$_opts.skipChunkSize) || SKIP_SMALL_CHUNK))
5071
5087
  return;
5088
+ this._totalSize += totalByte;
5089
+ this._totalCost += ms;
5072
5090
  this._chunkSpeed = 8e3 * totalByte / ms;
5073
5091
  this._chunkCache.push({
5074
5092
  size: totalByte,
@@ -5118,11 +5136,23 @@
5118
5136
  }
5119
5137
  return this._chunkSpeed;
5120
5138
  }
5139
+ }, {
5140
+ key: "getTotalSize",
5141
+ value: function getTotalSize() {
5142
+ return this._totalSize;
5143
+ }
5144
+ }, {
5145
+ key: "getTotalCost",
5146
+ value: function getTotalCost() {
5147
+ return this._totalCost;
5148
+ }
5121
5149
  }, {
5122
5150
  key: "reset",
5123
5151
  value: function reset() {
5124
5152
  this._chunkCache = [];
5125
5153
  this._speeds = [];
5154
+ this._totalSize = 0;
5155
+ this._totalCost = 0;
5126
5156
  }
5127
5157
  }]);
5128
5158
  return BandwidthService2;
@@ -5251,13 +5281,15 @@
5251
5281
  _createClass$2(MediaStatsService2, [{
5252
5282
  key: "getStats",
5253
5283
  value: function getStats() {
5254
- var _this$_core, _this$_core2, _this$_core2$speedInf, _this$_core3, _this$_core3$speedInf, _this$_core4, _this$_core4$bufferIn;
5284
+ 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;
5255
5285
  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;
5256
5286
  return _objectSpread2(_objectSpread2({}, this._stats.getStats()), {}, {
5257
5287
  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,
5258
5288
  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,
5289
+ 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,
5290
+ 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,
5259
5291
  currentTime,
5260
- 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,
5292
+ 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,
5261
5293
  decodeFps
5262
5294
  });
5263
5295
  }
@@ -10451,7 +10483,7 @@
10451
10483
  _createClass$4(Flv2, [{
10452
10484
  key: "version",
10453
10485
  get: function get() {
10454
- return "3.0.18-alpha.3";
10486
+ return "3.0.19-rc.0";
10455
10487
  }
10456
10488
  }, {
10457
10489
  key: "isLive",
@@ -10485,7 +10517,9 @@
10485
10517
  value: function speedInfo() {
10486
10518
  return {
10487
10519
  speed: this._bandwidthService.getLatestSpeed(),
10488
- avgSpeed: this._bandwidthService.getAvgSpeed()
10520
+ avgSpeed: this._bandwidthService.getAvgSpeed(),
10521
+ totalSize: this._bandwidthService.getTotalSize(),
10522
+ totalCost: this._bandwidthService.getTotalCost()
10489
10523
  };
10490
10524
  }
10491
10525
  }, {
@@ -10775,7 +10809,7 @@
10775
10809
  _context9.prev = 17;
10776
10810
  _context9.t0 = _context9["catch"](12);
10777
10811
  this._loading = false;
10778
- return _context9.abrupt("return", this._emitError(StreamingError.network(_context9.t0)));
10812
+ return _context9.abrupt("return", this._emitError(StreamingError.network(_context9.t0), false));
10779
10813
  case 21:
10780
10814
  case "end":
10781
10815
  return _context9.stop();