@volcengine/veplayer-plugin 2.12.0-rc.0 → 2.12.0-rc.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.
Files changed (43) hide show
  1. package/esm/index.development.js +537 -246
  2. package/esm/index.production.js +3 -3
  3. package/esm/veplayer.plugin.abr.development.js +3 -1
  4. package/esm/veplayer.plugin.abr.production.js +1 -1
  5. package/esm/veplayer.plugin.ad.development.js +18 -4
  6. package/esm/veplayer.plugin.ad.production.js +2 -2
  7. package/esm/veplayer.plugin.drm.development.js +3 -1
  8. package/esm/veplayer.plugin.drm.production.js +1 -1
  9. package/esm/veplayer.plugin.flv.development.js +5 -3
  10. package/esm/veplayer.plugin.flv.production.js +1 -1
  11. package/esm/veplayer.plugin.hls.development.js +64 -14
  12. package/esm/veplayer.plugin.hls.production.js +1 -1
  13. package/esm/veplayer.plugin.hlsjs.development.js +3 -1
  14. package/esm/veplayer.plugin.hlsjs.production.js +1 -1
  15. package/esm/veplayer.plugin.mp4.development.js +9 -3
  16. package/esm/veplayer.plugin.mp4.production.js +1 -1
  17. package/esm/veplayer.plugin.rtm.development.js +293 -151
  18. package/esm/veplayer.plugin.rtm.production.js +1 -1
  19. package/esm/veplayer.plugin.shaka.development.js +8 -2
  20. package/esm/veplayer.plugin.shaka.production.js +2 -2
  21. package/esm/veplayer.strategy.base.development.js +163 -78
  22. package/esm/veplayer.strategy.base.production.js +1 -1
  23. package/package.json +1 -1
  24. package/umd/veplayer.plugin.abr.development.js +3 -1
  25. package/umd/veplayer.plugin.abr.production.js +1 -1
  26. package/umd/veplayer.plugin.ad.development.js +18 -4
  27. package/umd/veplayer.plugin.ad.production.js +1 -1
  28. package/umd/veplayer.plugin.drm.development.js +3 -1
  29. package/umd/veplayer.plugin.drm.production.js +1 -1
  30. package/umd/veplayer.plugin.flv.development.js +5 -3
  31. package/umd/veplayer.plugin.flv.production.js +1 -1
  32. package/umd/veplayer.plugin.hls.development.js +64 -14
  33. package/umd/veplayer.plugin.hls.production.js +1 -1
  34. package/umd/veplayer.plugin.hlsjs.development.js +3 -1
  35. package/umd/veplayer.plugin.hlsjs.production.js +1 -1
  36. package/umd/veplayer.plugin.mp4.development.js +9 -3
  37. package/umd/veplayer.plugin.mp4.production.js +1 -1
  38. package/umd/veplayer.plugin.rtm.development.js +293 -151
  39. package/umd/veplayer.plugin.rtm.production.js +1 -1
  40. package/umd/veplayer.plugin.shaka.development.js +8 -2
  41. package/umd/veplayer.plugin.shaka.production.js +1 -1
  42. package/umd/veplayer.strategy.base.development.js +163 -78
  43. package/umd/veplayer.strategy.base.production.js +1 -1
@@ -1641,7 +1641,7 @@ util.getCurrentTimeByOffset = function(offsetTime, segments) {
1641
1641
  }
1642
1642
  return offsetTime;
1643
1643
  };
1644
- var version = "3.0.21-rc.21";
1644
+ var version = "3.0.24-rc.6";
1645
1645
  var ERROR_MAP = {
1646
1646
  1: 5101,
1647
1647
  2: 5102,
@@ -1750,7 +1750,7 @@ function hook(hookName, handler) {
1750
1750
  }
1751
1751
  if (this.__hooks && this.__hooks[hookName]) {
1752
1752
  try {
1753
- var preRet = runHooks(this, hookName, handler);
1753
+ var preRet = runHooks.apply(void 0, [this, hookName, handler].concat(Array.prototype.slice.call(arguments)));
1754
1754
  if (preRet) {
1755
1755
  if (preRet.then) {
1756
1756
  preRet.then(function(isContinue) {
@@ -1864,6 +1864,8 @@ function runHooks(obj, hookName, handler) {
1864
1864
  });
1865
1865
  } else if (ret !== false) {
1866
1866
  return runHooksRecursive2.apply(void 0, [obj2, hookName2, handler2].concat(args2));
1867
+ } else if (ret === false) {
1868
+ return false;
1867
1869
  }
1868
1870
  };
1869
1871
  return runHooksRecursive.apply(void 0, [obj, hookName, handler].concat(args));
@@ -3929,7 +3931,8 @@ var MSE = /* @__PURE__ */ function() {
3929
3931
  key: "isSupported",
3930
3932
  value: function isSupported() {
3931
3933
  var mime = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';
3932
- var MediaSource2 = getMediaSource();
3934
+ var preferMMS = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
3935
+ var MediaSource2 = getMediaSource(preferMMS);
3933
3936
  if (!MediaSource2)
3934
3937
  return false;
3935
3938
  try {
@@ -4125,6 +4128,7 @@ var FetchLoader = /* @__PURE__ */ function(_EventEmitter) {
4125
4128
  _defineProperty$1(_assertThisInitialized$1(_this), "_running", false);
4126
4129
  _defineProperty$1(_assertThisInitialized$1(_this), "_logger", null);
4127
4130
  _defineProperty$1(_assertThisInitialized$1(_this), "_vid", "");
4131
+ _defineProperty$1(_assertThisInitialized$1(_this), "_firtstByte", 0);
4128
4132
  _defineProperty$1(_assertThisInitialized$1(_this), "_onProcessMinLen", 0);
4129
4133
  _defineProperty$1(_assertThisInitialized$1(_this), "_onCancel", null);
4130
4134
  _defineProperty$1(_assertThisInitialized$1(_this), "_priOptions", null);
@@ -4134,7 +4138,7 @@ var FetchLoader = /* @__PURE__ */ function(_EventEmitter) {
4134
4138
  key: "load",
4135
4139
  value: function load(_ref) {
4136
4140
  var _this$_abortControlle, _this2 = this;
4137
- 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;
4141
+ 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;
4138
4142
  this._logger = logger2;
4139
4143
  this._aborted = false;
4140
4144
  this._onProcessMinLen = onProcessMinLen;
@@ -4145,6 +4149,7 @@ var FetchLoader = /* @__PURE__ */ function(_EventEmitter) {
4145
4149
  this._range = range || [0, 0];
4146
4150
  this._vid = vid || url;
4147
4151
  this._priOptions = priOptions || {};
4152
+ this._firstMaxChunkSize = firstMaxChunkSize;
4148
4153
  var init = {
4149
4154
  method,
4150
4155
  headers,
@@ -4192,7 +4197,10 @@ var FetchLoader = /* @__PURE__ */ function(_EventEmitter) {
4192
4197
  var startTime = Date.now();
4193
4198
  this._logger.debug("[fetch load start], index,", index, ",range,", range);
4194
4199
  return new Promise(function(resolve, reject) {
4195
- fetch(request || url, request ? void 0 : init).then(/* @__PURE__ */ function() {
4200
+ var promise = streamRes ? new Promise(function(r) {
4201
+ r(streamRes);
4202
+ }) : fetch(request || url, request ? void 0 : init);
4203
+ promise.then(/* @__PURE__ */ function() {
4196
4204
  var _ref2 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(response) {
4197
4205
  var firstByteTime, data, costTime, speed;
4198
4206
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -4388,7 +4396,7 @@ var FetchLoader = /* @__PURE__ */ function(_EventEmitter) {
4388
4396
  var pump = /* @__PURE__ */ function() {
4389
4397
  var _ref3 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee3() {
4390
4398
  var _this3$_range;
4391
- var startRange, startByte, curLen, retData, temp, costTime, speed;
4399
+ var startRange, startByte, curLen, retData, temp, tmp, _tmp, costTime, speed;
4392
4400
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
4393
4401
  while (1)
4394
4402
  switch (_context3.prev = _context3.next) {
@@ -4467,6 +4475,20 @@ var FetchLoader = /* @__PURE__ */ function(_EventEmitter) {
4467
4475
  retData = data.value;
4468
4476
  }
4469
4477
  if (retData && retData.byteLength > 0 || data.done) {
4478
+ if (_this3._firstMaxChunkSize) {
4479
+ if (!_this3._firtstByte) {
4480
+ _this3._firtstByte++;
4481
+ tmp = retData.slice(0, _this3._firstMaxChunkSize);
4482
+ _this3._cacheData = retData.slice(_this3._firstMaxChunkSize);
4483
+ retData = tmp;
4484
+ } else if (_this3._cacheData) {
4485
+ _tmp = new Uint8Array(_this3._cacheData.byteLength + retData.byteLength);
4486
+ _tmp.set(_this3._cacheData, 0);
4487
+ _tmp.set(retData, _this3._cacheData.byteLength);
4488
+ retData = _tmp;
4489
+ _this3._cacheData = null;
4490
+ }
4491
+ }
4470
4492
  onProgress(retData, data.done, {
4471
4493
  range: [_this3._range[0] + _this3._receivedLength - (retData ? retData.byteLength : 0), _this3._range[0] + _this3._receivedLength],
4472
4494
  vid: _this3._vid,
@@ -4479,7 +4501,13 @@ var FetchLoader = /* @__PURE__ */ function(_EventEmitter) {
4479
4501
  }, response);
4480
4502
  }
4481
4503
  if (!data.done) {
4482
- pump();
4504
+ if (_this3._firstMaxChunkSize) {
4505
+ setTimeout(function() {
4506
+ pump();
4507
+ }, 0);
4508
+ } else {
4509
+ pump();
4510
+ }
4483
4511
  } else {
4484
4512
  costTime = Date.now() - st;
4485
4513
  speed = calculateSpeed(_this3._receivedLength, costTime);
@@ -6201,7 +6229,7 @@ var AAC = /* @__PURE__ */ function() {
6201
6229
  objectType = 2;
6202
6230
  extensionSamplingIndex = samplingIndex;
6203
6231
  } else {
6204
- objectType = originObjectType === 2 || originObjectType === 5 ? originObjectType : 5;
6232
+ objectType = 5;
6205
6233
  extensionSamplingIndex = samplingIndex;
6206
6234
  if (samplingIndex >= 6) {
6207
6235
  extensionSamplingIndex = samplingIndex - 3;
@@ -7134,7 +7162,7 @@ var TsFixer = /* @__PURE__ */ function() {
7134
7162
  x.pts += vDelta;
7135
7163
  });
7136
7164
  } else {
7137
- for (var i = 1; i < len - 1; i++) {
7165
+ for (var i = 1; i <= len - 1; i++) {
7138
7166
  var _samples$i;
7139
7167
  var dts = (_samples$i = samples[i]) === null || _samples$i === void 0 ? void 0 : _samples$i.dts;
7140
7168
  var prevDts = samples[i - 1].dts;
@@ -8694,6 +8722,13 @@ var MP4Parser = /* @__PURE__ */ function() {
8694
8722
  }
8695
8723
  ret.objectType = objectType;
8696
8724
  ret.codec += objectType.toString(16);
8725
+ if (/^mp4a/ig.test(ret.codec) && config.length >= 2) {
8726
+ var samplingFrequencyIndex = (config[0] & 7) << 1 | (config[1] & 128) >> 7;
8727
+ ret.samplingFrequencyIndex = samplingFrequencyIndex;
8728
+ if (samplingFrequencyIndex < AAC.FREQ.length) {
8729
+ ret.sampleRate = AAC.FREQ[samplingFrequencyIndex];
8730
+ }
8731
+ }
8697
8732
  if (ret.codec[ret.codec.length - 1] === ".") {
8698
8733
  ret.codec = ret.codec.substring(0, ret.codec.length - 1);
8699
8734
  }
@@ -8982,7 +9017,9 @@ var MP4Parser = /* @__PURE__ */ function() {
8982
9017
  v.codecType = VideoCodecType.AV1;
8983
9018
  v.codec = e1.av1C.codec;
8984
9019
  v.av1C = e1.av1C.data;
8985
- v.colr = e1.colr.data;
9020
+ if (e1.colr) {
9021
+ v.colr = e1.colr.data;
9022
+ }
8986
9023
  } else if (e1.hvcC) {
8987
9024
  v.codecType = VideoCodecType.HEVC;
8988
9025
  v.codec = e1.hvcC.codec;
@@ -9028,7 +9065,7 @@ var MP4Parser = /* @__PURE__ */ function() {
9028
9065
  a.duration = aTrack.mdia.mdhd.duration || a.mvhdDurtion / a.mvhdTimecale * a.timescale;
9029
9066
  var _e = aTrack.mdia.minf.stbl.stsd.entries[0];
9030
9067
  a.sampleSize = _e.sampleSize;
9031
- a.sampleRate = _e.sampleRate;
9068
+ a.sampleRate = getAudioSampleRate(_e);
9032
9069
  a.channelCount = _e.channelCount;
9033
9070
  a.present = true;
9034
9071
  switch (_e.type) {
@@ -9211,6 +9248,19 @@ var MP4Parser = /* @__PURE__ */ function() {
9211
9248
  }]);
9212
9249
  return MP4Parser2;
9213
9250
  }();
9251
+ function getAudioSampleRate(audioSampleEntry) {
9252
+ var sampleRate = 0;
9253
+ if (audioSampleEntry.type === "mp4a") {
9254
+ if (audioSampleEntry.sampleRate > 0) {
9255
+ sampleRate = audioSampleEntry.sampleRate;
9256
+ } else {
9257
+ sampleRate = audioSampleEntry.esds.sampleRate;
9258
+ }
9259
+ } else {
9260
+ sampleRate = audioSampleEntry.sampleRate;
9261
+ }
9262
+ return sampleRate || 0;
9263
+ }
9214
9264
  function getSamples(stts, stsc, stsz, stco, ctts, stss) {
9215
9265
  var samples = [];
9216
9266
  var cttsEntries = ctts === null || ctts === void 0 ? void 0 : ctts.entries;
@@ -14561,7 +14611,7 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
14561
14611
  if (!_this.media)
14562
14612
  return;
14563
14613
  var cfg = _this.config;
14564
- if (cfg.isLive && cfg.maxLatency && cfg.targetLatency && _this.media) {
14614
+ if (cfg.isLive && cfg.maxLatency && cfg.targetLatency) {
14565
14615
  var liveEdge = _this._playlist.liveEdge;
14566
14616
  if (!liveEdge)
14567
14617
  return;
@@ -14575,7 +14625,7 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
14575
14625
  var _this$_seiService;
14576
14626
  (_this$_seiService = _this._seiService) === null || _this$_seiService === void 0 ? void 0 : _this$_seiService.throw(_this.media.currentTime);
14577
14627
  }
14578
- if (_this.config.allowedStreamTrackChange && !_this.config.softDecode) {
14628
+ if (cfg.allowedStreamTrackChange && !cfg.softDecode && _this.media.readyState) {
14579
14629
  _this._checkStreamTrackChange(_this.media.currentTime);
14580
14630
  }
14581
14631
  });
@@ -15753,7 +15803,7 @@ var Hls = /* @__PURE__ */ function(_EventEmitter) {
15753
15803
  }]);
15754
15804
  return Hls2;
15755
15805
  }(EventEmitter);
15756
- _defineProperty$3(Hls, "version", "3.0.21-rc.21");
15806
+ _defineProperty$3(Hls, "version", "3.0.24-rc.2");
15757
15807
  try {
15758
15808
  if (localStorage.getItem("xgd")) {
15759
15809
  Hls.enableLogger();