@volcengine/veplayer-plugin 2.8.1-rc.0 → 2.8.2

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": "@volcengine/veplayer-plugin",
3
- "version": "2.8.1-rc.0",
3
+ "version": "2.8.2",
4
4
  "main": "./umd/index.production.js",
5
5
  "module": "./esm/index.production.js",
6
6
  "browser": "./umd/index.production.js",
@@ -3835,7 +3835,8 @@ var __publicField = (obj, key, value) => {
3835
3835
  key: "isSupported",
3836
3836
  value: function isSupported() {
3837
3837
  var mime = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';
3838
- var MediaSource2 = getMediaSource();
3838
+ var preferMMS = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
3839
+ var MediaSource2 = getMediaSource(preferMMS);
3839
3840
  if (!MediaSource2)
3840
3841
  return false;
3841
3842
  try {
@@ -4031,6 +4032,7 @@ var __publicField = (obj, key, value) => {
4031
4032
  _defineProperty$1(_assertThisInitialized$2(_this), "_running", false);
4032
4033
  _defineProperty$1(_assertThisInitialized$2(_this), "_logger", null);
4033
4034
  _defineProperty$1(_assertThisInitialized$2(_this), "_vid", "");
4035
+ _defineProperty$1(_assertThisInitialized$2(_this), "_firtstByte", 0);
4034
4036
  _defineProperty$1(_assertThisInitialized$2(_this), "_onProcessMinLen", 0);
4035
4037
  _defineProperty$1(_assertThisInitialized$2(_this), "_onCancel", null);
4036
4038
  _defineProperty$1(_assertThisInitialized$2(_this), "_priOptions", null);
@@ -4040,7 +4042,7 @@ var __publicField = (obj, key, value) => {
4040
4042
  key: "load",
4041
4043
  value: function load(_ref) {
4042
4044
  var _this$_abortControlle, _this2 = this;
4043
- var url = _ref.url, vid = _ref.vid, timeout = _ref.timeout, responseType = _ref.responseType, onProgress = _ref.onProgress, index = _ref.index, onTimeout = _ref.onTimeout, onCancel = _ref.onCancel, range = _ref.range, transformResponse = _ref.transformResponse, request = _ref.request, params = _ref.params, logger2 = _ref.logger, method = _ref.method, headers = _ref.headers, body = _ref.body, mode = _ref.mode, credentials = _ref.credentials, cache = _ref.cache, redirect = _ref.redirect, referrer = _ref.referrer, referrerPolicy = _ref.referrerPolicy, onProcessMinLen = _ref.onProcessMinLen, priOptions = _ref.priOptions;
4045
+ var url = _ref.url, vid = _ref.vid, timeout = _ref.timeout, responseType = _ref.responseType, onProgress = _ref.onProgress, index = _ref.index, onTimeout = _ref.onTimeout, onCancel = _ref.onCancel, range = _ref.range, transformResponse = _ref.transformResponse, request = _ref.request, params = _ref.params, logger2 = _ref.logger, method = _ref.method, headers = _ref.headers, body = _ref.body, mode = _ref.mode, credentials = _ref.credentials, cache = _ref.cache, redirect = _ref.redirect, referrer = _ref.referrer, referrerPolicy = _ref.referrerPolicy, onProcessMinLen = _ref.onProcessMinLen, priOptions = _ref.priOptions, streamRes = _ref.streamRes, firstMaxChunkSize = _ref.firstMaxChunkSize;
4044
4046
  this._logger = logger2;
4045
4047
  this._aborted = false;
4046
4048
  this._onProcessMinLen = onProcessMinLen;
@@ -4051,6 +4053,7 @@ var __publicField = (obj, key, value) => {
4051
4053
  this._range = range || [0, 0];
4052
4054
  this._vid = vid || url;
4053
4055
  this._priOptions = priOptions || {};
4056
+ this._firstMaxChunkSize = firstMaxChunkSize;
4054
4057
  var init = {
4055
4058
  method,
4056
4059
  headers,
@@ -4098,7 +4101,10 @@ var __publicField = (obj, key, value) => {
4098
4101
  var startTime = Date.now();
4099
4102
  this._logger.debug("[fetch load start], index,", index, ",range,", range);
4100
4103
  return new Promise(function(resolve, reject) {
4101
- fetch(request || url, request ? void 0 : init).then(/* @__PURE__ */ function() {
4104
+ var promise = streamRes ? new Promise(function(r) {
4105
+ r(streamRes);
4106
+ }) : fetch(request || url, request ? void 0 : init);
4107
+ promise.then(/* @__PURE__ */ function() {
4102
4108
  var _ref2 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(response) {
4103
4109
  var firstByteTime, data, costTime, speed;
4104
4110
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -4294,7 +4300,7 @@ var __publicField = (obj, key, value) => {
4294
4300
  var pump = /* @__PURE__ */ function() {
4295
4301
  var _ref3 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee3() {
4296
4302
  var _this3$_range;
4297
- var startRange, startByte, curLen, retData, temp, costTime, speed;
4303
+ var startRange, startByte, curLen, retData, temp, tmp, _tmp, costTime, speed;
4298
4304
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
4299
4305
  while (1)
4300
4306
  switch (_context3.prev = _context3.next) {
@@ -4373,6 +4379,20 @@ var __publicField = (obj, key, value) => {
4373
4379
  retData = data.value;
4374
4380
  }
4375
4381
  if (retData && retData.byteLength > 0 || data.done) {
4382
+ if (_this3._firstMaxChunkSize) {
4383
+ if (!_this3._firtstByte) {
4384
+ _this3._firtstByte++;
4385
+ tmp = retData.slice(0, _this3._firstMaxChunkSize);
4386
+ _this3._cacheData = retData.slice(_this3._firstMaxChunkSize);
4387
+ retData = tmp;
4388
+ } else if (_this3._cacheData) {
4389
+ _tmp = new Uint8Array(_this3._cacheData.byteLength + retData.byteLength);
4390
+ _tmp.set(_this3._cacheData, 0);
4391
+ _tmp.set(retData, _this3._cacheData.byteLength);
4392
+ retData = _tmp;
4393
+ _this3._cacheData = null;
4394
+ }
4395
+ }
4376
4396
  onProgress(retData, data.done, {
4377
4397
  range: [_this3._range[0] + _this3._receivedLength - (retData ? retData.byteLength : 0), _this3._range[0] + _this3._receivedLength],
4378
4398
  vid: _this3._vid,
@@ -4385,7 +4405,13 @@ var __publicField = (obj, key, value) => {
4385
4405
  }, response);
4386
4406
  }
4387
4407
  if (!data.done) {
4388
- pump();
4408
+ if (_this3._firstMaxChunkSize) {
4409
+ setTimeout(function() {
4410
+ pump();
4411
+ }, 0);
4412
+ } else {
4413
+ pump();
4414
+ }
4389
4415
  } else {
4390
4416
  costTime = Date.now() - st;
4391
4417
  speed = calculateSpeed(_this3._receivedLength, costTime);
@@ -6062,7 +6088,7 @@ var __publicField = (obj, key, value) => {
6062
6088
  objectType = 2;
6063
6089
  extensionSamplingIndex = samplingIndex;
6064
6090
  } else {
6065
- objectType = originObjectType === 2 || originObjectType === 5 ? originObjectType : 5;
6091
+ objectType = 5;
6066
6092
  extensionSamplingIndex = samplingIndex;
6067
6093
  if (samplingIndex >= 6) {
6068
6094
  extensionSamplingIndex = samplingIndex - 3;
@@ -7593,8 +7619,10 @@ var __publicField = (obj, key, value) => {
7593
7619
  if (metaData.hasOwnProperty("duration")) {
7594
7620
  videoTrack.duration = metaData.duration * 1e3;
7595
7621
  }
7596
- if (metaData.hasOwnProperty("width") && metaData.hasOwnProperty("height")) {
7622
+ if (!videoTrack.width && metaData.hasOwnProperty("width")) {
7597
7623
  videoTrack.width = metaData.width;
7624
+ }
7625
+ if (!videoTrack.height && metaData.hasOwnProperty("height")) {
7598
7626
  videoTrack.height = metaData.height;
7599
7627
  }
7600
7628
  }
@@ -11002,7 +11030,7 @@ var __publicField = (obj, key, value) => {
11002
11030
  _createClass$4(Flv2, [{
11003
11031
  key: "version",
11004
11032
  get: function get() {
11005
- return "3.0.21-rc.21";
11033
+ return "3.0.23-rc.6";
11006
11034
  }
11007
11035
  }, {
11008
11036
  key: "isLive",
@@ -11062,25 +11090,26 @@ var __publicField = (obj, key, value) => {
11062
11090
  key: "load",
11063
11091
  value: function() {
11064
11092
  var _load = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee4(url) {
11065
- var reuseMse, _args4 = arguments;
11093
+ var reuseMse, streamRes, _args4 = arguments;
11066
11094
  return _regeneratorRuntime$1().wrap(function _callee4$(_context4) {
11067
11095
  while (1)
11068
11096
  switch (_context4.prev = _context4.next) {
11069
11097
  case 0:
11070
11098
  reuseMse = _args4.length > 1 && _args4[1] !== void 0 ? _args4[1] : false;
11099
+ streamRes = _args4.length > 2 ? _args4[2] : void 0;
11071
11100
  if (this._bufferService) {
11072
- _context4.next = 3;
11101
+ _context4.next = 4;
11073
11102
  break;
11074
11103
  }
11075
11104
  return _context4.abrupt("return");
11076
- case 3:
11077
- _context4.next = 5;
11105
+ case 4:
11106
+ _context4.next = 6;
11078
11107
  return this._reset(reuseMse);
11079
- case 5:
11080
- this._loadData(url, this._opts.isLive ? [] : [0, this._opts.defaultVodLoadSize]);
11108
+ case 6:
11109
+ this._loadData(url, this._opts.isLive ? [] : [0, this._opts.defaultVodLoadSize], streamRes);
11081
11110
  clearTimeout(this._tickTimer);
11082
11111
  this._tickTimer = setTimeout(this._tick, this._tickInterval);
11083
- case 8:
11112
+ case 9:
11084
11113
  case "end":
11085
11114
  return _context4.stop();
11086
11115
  }
@@ -11315,7 +11344,7 @@ var __publicField = (obj, key, value) => {
11315
11344
  }, {
11316
11345
  key: "_loadData",
11317
11346
  value: function() {
11318
- var _loadData2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee10(url, range) {
11347
+ var _loadData2 = _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee10(url, range, streamRes) {
11319
11348
  var finnalUrl;
11320
11349
  return _regeneratorRuntime$1().wrap(function _callee10$(_context10) {
11321
11350
  while (1)
@@ -11351,7 +11380,9 @@ var __publicField = (obj, key, value) => {
11351
11380
  _context10.next = 15;
11352
11381
  return this._mediaLoader.load({
11353
11382
  url: finnalUrl,
11354
- range
11383
+ range,
11384
+ streamRes,
11385
+ firstMaxChunkSize: this._opts.firstMaxChunkSize
11355
11386
  });
11356
11387
  case 15:
11357
11388
  _context10.next = 21;
@@ -11367,7 +11398,7 @@ var __publicField = (obj, key, value) => {
11367
11398
  }
11368
11399
  }, _callee10, this, [[12, 17]]);
11369
11400
  }));
11370
- function _loadData(_x9, _x10) {
11401
+ function _loadData(_x9, _x10, _x11) {
11371
11402
  return _loadData2.apply(this, arguments);
11372
11403
  }
11373
11404
  return _loadData;
@@ -11533,6 +11564,12 @@ var __publicField = (obj, key, value) => {
11533
11564
  var _this$flv;
11534
11565
  return (_this$flv = _this.flv) === null || _this$flv === void 0 ? void 0 : _this$flv.getStats();
11535
11566
  });
11567
+ _defineProperty$3(_assertThisInitialized$3(_this), "loadSource", function() {
11568
+ var _this$flv2;
11569
+ arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : _this.player.config.url;
11570
+ var streamRes = arguments.length > 1 ? arguments[1] : void 0;
11571
+ (_this$flv2 = _this.flv) === null || _this$flv2 === void 0 ? void 0 : _this$flv2.load(_this.player.config.url, true, streamRes);
11572
+ });
11536
11573
  _defineProperty$3(_assertThisInitialized$3(_this), "destroy", function() {
11537
11574
  var _this$pluginExtension;
11538
11575
  if (_this.flv) {
@@ -11578,8 +11615,8 @@ var __publicField = (obj, key, value) => {
11578
11615
  }, {
11579
11616
  key: "version",
11580
11617
  get: function get() {
11581
- var _this$flv2;
11582
- return (_this$flv2 = this.flv) === null || _this$flv2 === void 0 ? void 0 : _this$flv2.version;
11618
+ var _this$flv3;
11619
+ return (_this$flv3 = this.flv) === null || _this$flv3 === void 0 ? void 0 : _this$flv3.version;
11583
11620
  }
11584
11621
  }, {
11585
11622
  key: "softDecode",
@@ -11591,8 +11628,8 @@ var __publicField = (obj, key, value) => {
11591
11628
  }, {
11592
11629
  key: "loader",
11593
11630
  get: function get() {
11594
- var _this$flv3;
11595
- return (_this$flv3 = this.flv) === null || _this$flv3 === void 0 ? void 0 : _this$flv3.loader;
11631
+ var _this$flv4;
11632
+ return (_this$flv4 = this.flv) === null || _this$flv4 === void 0 ? void 0 : _this$flv4.loader;
11596
11633
  }
11597
11634
  }, {
11598
11635
  key: "transferCost",
@@ -11679,7 +11716,9 @@ var __publicField = (obj, key, value) => {
11679
11716
  this._transCoreEvent(EVENT.STREAM_EXCEPTION);
11680
11717
  this._transCoreEvent(EVENT.SWITCH_URL_SUCCESS);
11681
11718
  this._transCoreEvent(EVENT.SWITCH_URL_FAILED);
11682
- this.flv.load(config.url, true);
11719
+ if (!flvOpts.manualLoad) {
11720
+ this.loadSource(config.url, flvOpts.streamRes);
11721
+ }
11683
11722
  }
11684
11723
  }, {
11685
11724
  key: "_transError",