@volcengine/veplayer 2.4.0-rc.3 → 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.
Files changed (40) hide show
  1. package/esm/index.d.ts +22 -6
  2. package/esm/veplayer.biz.live.development.js +192 -102
  3. package/esm/veplayer.biz.live.production.js +1 -1
  4. package/esm/veplayer.d.ts +551 -106
  5. package/esm/veplayer.development.css +1 -1
  6. package/esm/veplayer.development.js +263 -134
  7. package/esm/veplayer.live.d.ts +551 -106
  8. package/esm/veplayer.live.development.css +1 -1
  9. package/esm/veplayer.live.development.js +263 -134
  10. package/esm/veplayer.live.production.css +1 -1
  11. package/esm/veplayer.live.production.js +3 -3
  12. package/esm/veplayer.production.css +1 -1
  13. package/esm/veplayer.production.js +3 -3
  14. package/esm/veplayer.vod.d.ts +22 -6
  15. package/esm/veplayer.vod.development.css +1 -1
  16. package/esm/veplayer.vod.development.js +65 -27
  17. package/esm/veplayer.vod.production.css +1 -1
  18. package/esm/veplayer.vod.production.js +2 -2
  19. package/package.json +1 -1
  20. package/umd/index.d.ts +22 -6
  21. package/umd/veplayer.biz.live.development.js +192 -102
  22. package/umd/veplayer.biz.live.production.js +1 -1
  23. package/umd/veplayer.d.ts +551 -106
  24. package/umd/veplayer.development.css +1 -1
  25. package/umd/veplayer.development.js +263 -134
  26. package/umd/veplayer.live.d.ts +551 -106
  27. package/umd/veplayer.live.development.css +1 -1
  28. package/umd/veplayer.live.development.js +263 -134
  29. package/umd/veplayer.live.production.css +1 -1
  30. package/umd/veplayer.live.production.js +1 -1
  31. package/umd/veplayer.production.css +1 -1
  32. package/umd/veplayer.production.js +1 -1
  33. package/umd/veplayer.vod.d.ts +22 -6
  34. package/umd/veplayer.vod.development.css +1 -1
  35. package/umd/veplayer.vod.development.js +65 -27
  36. package/umd/veplayer.vod.production.css +1 -1
  37. package/umd/veplayer.vod.production.js +1 -1
  38. package/veplayer.d.ts +551 -106
  39. package/veplayer.live.d.ts +551 -106
  40. package/veplayer.vod.d.ts +22 -6
@@ -1457,7 +1457,7 @@ var sniffer$1 = {
1457
1457
  }
1458
1458
  }
1459
1459
  };
1460
- var version = "3.0.17";
1460
+ var version = "3.0.19-rc.0";
1461
1461
  var ERROR_TYPE_MAP = {
1462
1462
  1: "media",
1463
1463
  2: "media",
@@ -4542,7 +4542,11 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
4542
4542
  _this._fullScreenOffset = null;
4543
4543
  }
4544
4544
  if (!_this.cssfullscreen) {
4545
- _this.recoverFullStyle(_this.root, _this._fullscreenEl, STATE_CLASS.FULLSCREEN);
4545
+ var el = _this._fullscreenEl;
4546
+ if (!el && (_this.root.contains(event.target) || event.target === _this.root)) {
4547
+ el = event.target;
4548
+ }
4549
+ _this.recoverFullStyle(_this.root, el, STATE_CLASS.FULLSCREEN);
4546
4550
  } else {
4547
4551
  _this.removeClass(STATE_CLASS.FULLSCREEN);
4548
4552
  }
@@ -5490,6 +5494,9 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5490
5494
  value: function getFullscreen() {
5491
5495
  var el = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.config.fullscreenTarget;
5492
5496
  var root2 = this.root, media = this.media;
5497
+ if (el === "video" || el === "media") {
5498
+ el = this[el];
5499
+ }
5493
5500
  if (!el) {
5494
5501
  el = root2;
5495
5502
  }
@@ -5724,19 +5731,15 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5724
5731
  this.isCanplay = true;
5725
5732
  this.waitTimer && util$1.clearTimeout(this, this.waitTimer);
5726
5733
  }
5727
- }, {
5728
- key: "onDurationchange",
5729
- value: function onDurationchange() {
5730
- if (this.__startTime > 0 && this.duration > 0) {
5731
- this.currentTime = this.__startTime;
5732
- this.__startTime = -1;
5733
- }
5734
- }
5735
5734
  }, {
5736
5735
  key: "onLoadeddata",
5737
5736
  value: function onLoadeddata() {
5738
5737
  this.isError = false;
5739
5738
  this.isSeeking = false;
5739
+ if (this.__startTime > 0 && this.duration > 0) {
5740
+ this.currentTime = this.__startTime;
5741
+ this.__startTime = -1;
5742
+ }
5740
5743
  }
5741
5744
  }, {
5742
5745
  key: "onLoadstart",
@@ -5839,7 +5842,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5839
5842
  util$1.clearTimeout(this, this.waitTimer);
5840
5843
  this.waitTimer = null;
5841
5844
  }
5842
- if (!this.paused && this.state < STATES.RUNNING && this.duration) {
5845
+ if (!this.paused && this.state === STATES.NOTALLOW && this.duration) {
5843
5846
  this.setState(STATES.RUNNING);
5844
5847
  this.emit(AUTOPLAY_STARTED);
5845
5848
  }
@@ -6091,8 +6094,9 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6091
6094
  }, {
6092
6095
  key: "_preProcessUrl",
6093
6096
  value: function _preProcessUrl(url, ext) {
6094
- var preProcessUrl = this.config.preProcessUrl;
6095
- return !util$1.isBlob(url) && typeof preProcessUrl === "function" ? preProcessUrl(url, ext) : {
6097
+ var _this$config7 = this.config, preProcessUrl = _this$config7.preProcessUrl, preProcessUrlOptions = _this$config7.preProcessUrlOptions;
6098
+ var processUrlOptions = Object.assign({}, preProcessUrlOptions, ext);
6099
+ return !util$1.isBlob(url) && typeof preProcessUrl === "function" ? preProcessUrl(url, processUrlOptions) : {
6096
6100
  url
6097
6101
  };
6098
6102
  }
@@ -6785,13 +6789,23 @@ var Poster = /* @__PURE__ */ function(_Plugin) {
6785
6789
  });
6786
6790
  }
6787
6791
  }
6792
+ }, {
6793
+ key: "setConfig",
6794
+ value: function setConfig(config) {
6795
+ var _this2 = this;
6796
+ Object.keys(config).forEach(function(key) {
6797
+ _this2.config[key] = config[key];
6798
+ });
6799
+ var poster = this.config.poster;
6800
+ this.update(poster);
6801
+ }
6788
6802
  }, {
6789
6803
  key: "onTimeUpdate",
6790
6804
  value: function onTimeUpdate() {
6791
- var _this2 = this;
6805
+ var _this3 = this;
6792
6806
  if (!this.player.currentTime) {
6793
6807
  this.once(TIME_UPDATE, function() {
6794
- _this2.onTimeUpdate();
6808
+ _this3.onTimeUpdate();
6795
6809
  });
6796
6810
  } else {
6797
6811
  util$1.removeClass(this.root, "xg-showplay");
@@ -8306,7 +8320,6 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
8306
8320
  if (scope === -1 || scope > 0 && !config.gestureY || scope === 0 && !config.gestureX) {
8307
8321
  return;
8308
8322
  }
8309
- e3.cancelable && e3.preventDefault();
8310
8323
  _this.executeMove(diffx, diffy, scope, pos.width, pos.height);
8311
8324
  pos.x = x2;
8312
8325
  pos.y = y2;
@@ -8348,8 +8361,7 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
8348
8361
  }
8349
8362
  });
8350
8363
  _defineProperty$1(_assertThisInitialized(_this), "onRootTouchEnd", function(e3) {
8351
- if (_this.pos.isStart && _this.checkIsRootTarget(e3)) {
8352
- e3.stopPropagation();
8364
+ if (_this.pos.scope > -1) {
8353
8365
  _this.onTouchEnd(e3);
8354
8366
  }
8355
8367
  });
@@ -8422,6 +8434,13 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
8422
8434
  });
8423
8435
  player.root.addEventListener("touchmove", this.onRootTouchMove, true);
8424
8436
  player.root.addEventListener("touchend", this.onRootTouchEnd, true);
8437
+ player.root.addEventListener("touchcancel", this.onRootTouchEnd, true);
8438
+ var controls = this.player.controls;
8439
+ if (controls && controls.center) {
8440
+ controls.center.addEventListener("touchmove", this.onRootTouchMove, true);
8441
+ controls.center.addEventListener("touchend", this.onRootTouchEnd, true);
8442
+ controls.center.addEventListener("touchcancel", this.onRootTouchEnd, true);
8443
+ }
8425
8444
  this.on(DURATION_CHANGE, function() {
8426
8445
  var player2 = _this2.player, config2 = _this2.config;
8427
8446
  if (player2.duration * 1e3 < config2.moveDuration) {
@@ -8821,6 +8840,13 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
8821
8840
  this.touch = null;
8822
8841
  player.root.removeEventListener("touchmove", this.onRootTouchMove, true);
8823
8842
  player.root.removeEventListener("touchend", this.onRootTouchEnd, true);
8843
+ player.root.removeEventListener("touchcancel", this.onRootTouchEnd, true);
8844
+ var controls = this.player.controls;
8845
+ if (controls && controls.center) {
8846
+ controls.center.removeEventListener("touchmove", this.onRootTouchMove, true);
8847
+ controls.center.removeEventListener("touchend", this.onRootTouchEnd, true);
8848
+ controls.center.removeEventListener("touchcancel", this.onRootTouchEnd, true);
8849
+ }
8824
8850
  }
8825
8851
  }, {
8826
8852
  key: "render",
@@ -9958,7 +9984,7 @@ var Volume = /* @__PURE__ */ function(_Plugin) {
9958
9984
  var _this$player2 = this.player, volume = _this$player2.volume, muted = _this$player2.muted;
9959
9985
  var $labelValue = this.find(".xgplayer-value-label");
9960
9986
  var vol = Math.max(Math.min(volume, 1), 0);
9961
- $labelValue.innerText = muted ? 0 : Math.ceil(vol * 100);
9987
+ $labelValue.innerText = muted ? 0 : Math.round(vol * 100);
9962
9988
  }
9963
9989
  }, {
9964
9990
  key: "focus",
@@ -10416,7 +10442,7 @@ var OptionList = /* @__PURE__ */ function() {
10416
10442
  }
10417
10443
  this.onItemClick = this.onItemClick.bind(this);
10418
10444
  this.renderItemList();
10419
- var eventName = sniffer$1.device === "mobile" ? "touchend" : "click";
10445
+ var eventName = this.config.domEventType === "touch" ? "touchend" : "click";
10420
10446
  this._delegates = Plugin.delegate.call(this, this.root, "li", eventName, this.onItemClick);
10421
10447
  }
10422
10448
  _createClass$1(OptionList2, [{
@@ -10620,9 +10646,9 @@ const BaseEvents = {
10620
10646
  AUTOPLAY_SUCCESS: "autoplaySuccess",
10621
10647
  ERROR_REFRESH_CLICK: "errorRefreshClick",
10622
10648
  SOURCE_CHANGE: "sourceChange",
10623
- SWITCH_DEFINITION_START: "switchDefinitionStart",
10624
- SWITCH_DEFINITION_SUCCESS: "switchDefinitionSuccess",
10625
- DOWN_DEFINITION: "downDefinition"
10649
+ ABR_SWITCH_START: "abrSwitchStart",
10650
+ ABR_SWITCH_SUCCESS: "abrSwitchSuccess",
10651
+ ABR_SWITCH_FAILED: "abrSwitchFailed"
10626
10652
  };
10627
10653
  const Events$1 = {
10628
10654
  ...XGEvents,
@@ -10669,14 +10695,14 @@ const EVENT_TRANSFORMATION = {
10669
10695
  [BaseEvents.DOWNLOAD_SPEED_CHANGE]: {
10670
10696
  event: DOWNLOAD_SPEED_CHANGE
10671
10697
  },
10672
- [BaseEvents.SWITCH_DEFINITION_START]: {
10698
+ [BaseEvents.ABR_SWITCH_START]: {
10673
10699
  event: "switch_definition_start"
10674
10700
  },
10675
- [BaseEvents.SWITCH_DEFINITION_SUCCESS]: {
10701
+ [BaseEvents.ABR_SWITCH_SUCCESS]: {
10676
10702
  event: "switch_definition_success"
10677
10703
  },
10678
- [BaseEvents.DOWN_DEFINITION]: {
10679
- event: "down_definition"
10704
+ [BaseEvents.ABR_SWITCH_FAILED]: {
10705
+ event: "switch_definition_fail"
10680
10706
  }
10681
10707
  };
10682
10708
  function transform(event, callback) {
@@ -13711,6 +13737,13 @@ class VePlayerBase {
13711
13737
  var _a;
13712
13738
  return (_a = this._sourceManager.source) == null ? void 0 : _a.name;
13713
13739
  }
13740
+ /** {zh}
13741
+ * 获取播放器版本号
13742
+ * @returns
13743
+ */
13744
+ get playerVersion() {
13745
+ return "2.4.0-rc.4";
13746
+ }
13714
13747
  /** {zh}
13715
13748
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
13716
13749
  */
@@ -14055,6 +14088,11 @@ class VePlayerBase {
14055
14088
  blur(data) {
14056
14089
  return this._player.blur(data);
14057
14090
  }
14091
+ /** {zh}
14092
+ * @brief 判断浏览器是否支持播放格式
14093
+ * @param type 播放格式
14094
+ * @returns
14095
+ */
14058
14096
  canPlayType(type) {
14059
14097
  return this._player.canPlayType(type);
14060
14098
  }
@@ -18814,11 +18852,12 @@ class Lite {
18814
18852
  }
18815
18853
  }
18816
18854
  const getFlvStrategy = async (options) => {
18817
- var _a, _b, _c;
18855
+ var _a, _b, _c, _d, _e, _f;
18818
18856
  let mseStrategy;
18819
18857
  let softStrategy;
18820
18858
  const enableLowLatency = ((_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.enableLowLatency) && sniffer$1.device === "pc";
18821
- const abrPts = ((_b = options == null ? void 0 : options.flv) == null ? void 0 : _b.abrPts) ?? "-800";
18859
+ const enableFrameChasing = ((_c = (_b = options == null ? void 0 : options.flv) == null ? void 0 : _b.lowLatency) == null ? void 0 : _c.enableFrameChasing) ?? true;
18860
+ const abrPts = ((_e = (_d = options == null ? void 0 : options.flv) == null ? void 0 : _d.lowLatency) == null ? void 0 : _e.abrPts) ?? "-800";
18822
18861
  const codec = await getCodec(options);
18823
18862
  const isSoftDecode$1 = await isSoftDecode(options, codec);
18824
18863
  if (isSoftDecode$1) {
@@ -18835,7 +18874,7 @@ const getFlvStrategy = async (options) => {
18835
18874
  (mseStrategy == null ? void 0 : mseStrategy.module) && load(mseStrategy.module).catch(() => void 0),
18836
18875
  (softStrategy == null ? void 0 : softStrategy.module) && load(softStrategy.module).catch(() => void 0)
18837
18876
  ]);
18838
- (softModule == null ? void 0 : softModule.XGVideoPlugin) && ((_c = softStrategy == null ? void 0 : softStrategy.afterLoad) == null ? void 0 : _c.call(softStrategy, softModule == null ? void 0 : softModule.XGVideoPlugin));
18877
+ (softModule == null ? void 0 : softModule.XGVideoPlugin) && ((_f = softStrategy == null ? void 0 : softStrategy.afterLoad) == null ? void 0 : _f.call(softStrategy, softModule == null ? void 0 : softModule.XGVideoPlugin));
18839
18878
  const combineOptions$1 = combineOptions([mseStrategy, softStrategy]);
18840
18879
  const plugins = [];
18841
18880
  if (enableLowLatency) {
@@ -18843,7 +18882,7 @@ const getFlvStrategy = async (options) => {
18843
18882
  }
18844
18883
  if (mseModule) {
18845
18884
  plugins.push(mseModule.FlvPlugin);
18846
- if (enableLowLatency) {
18885
+ if (enableLowLatency && enableFrameChasing) {
18847
18886
  plugins.push(mseModule.Adaptive);
18848
18887
  }
18849
18888
  }
@@ -19850,7 +19889,7 @@ function getCommonLog(options) {
19850
19889
  live_sdk_version: getPlayerCore(player) || player.hlsOps ? "2" : "-1",
19851
19890
  player_sdk_version: player.version,
19852
19891
  // eslint-disable-next-line no-undef
19853
- logger_version: "1.1.0-alpha.7",
19892
+ logger_version: "1.1.0-alpha.10",
19854
19893
  // 由rollup 在编译时注入
19855
19894
  report_version: "5",
19856
19895
  product_line: options.product_line,
@@ -20654,9 +20693,29 @@ var XgLiveLogger = /* @__PURE__ */ function() {
20654
20693
  play_current_time: _this7.player.currentTime
20655
20694
  }, _this7.videoSize));
20656
20695
  return Promise.resolve(_this7.getRtcStats(playedTime, first)).then(function(stats) {
20657
- _this7.logmanager.push(Object.assign({}, _this7.log.playing, _objectSpread2({
20696
+ var flvStats = {};
20697
+ if (_this7.core) {
20698
+ if (_this7.core.getStats) {
20699
+ var _ref2 = _this7.core.getStats() || {}, bitrate = _ref2.bitrate, avgSpeed = _ref2.avgSpeed;
20700
+ Object.assign(flvStats, {
20701
+ bitrate,
20702
+ avg_speed: avgSpeed,
20703
+ rate: avgSpeed / bitrate
20704
+ });
20705
+ }
20706
+ if (_this7.core.getNetWorkInfo) {
20707
+ var _this7$core$core;
20708
+ var _ref3 = _this7.core.getNetWorkInfo() || {}, lostRate = _ref3.lostRate;
20709
+ var _ref4 = ((_this7$core$core = _this7.core.core) === null || _this7$core$core === void 0 ? void 0 : _this7$core$core._opts) || {}, networkEvaluateInterval = _ref4.networkEvaluateInterval;
20710
+ Object.assign(flvStats, {
20711
+ lostRate,
20712
+ networkEvaluateInterval
20713
+ });
20714
+ }
20715
+ }
20716
+ _this7.logmanager.push(Object.assign({}, _this7.log.playing, _objectSpread2(_objectSpread2({
20658
20717
  play_time: first ? 0 : playedTime
20659
- }, stats)), true);
20718
+ }, stats), flvStats)), true);
20660
20719
  _this7.log.playing.download_speed_array = [];
20661
20720
  _this7.log.playing.stall_time = 0;
20662
20721
  _this7.log.playing.stall_count = 0;
@@ -20677,7 +20736,7 @@ var XgLiveLogger = /* @__PURE__ */ function() {
20677
20736
  _this9.player.off("playing", _this9.handlePlayerPlaying);
20678
20737
  _this9.player.off("timeupdate", _this9.handlePlayerPlaying);
20679
20738
  if (_this9.core) {
20680
- var _ref2 = _this9.core.getStats() || {}, fps = _ref2.fps;
20739
+ var _ref5 = _this9.core.getStats() || {}, fps = _ref5.fps;
20681
20740
  _this9.commonParams.fps = fps;
20682
20741
  }
20683
20742
  return Promise.resolve(_this9.reportPlaying(true)).then(function() {
@@ -20688,7 +20747,7 @@ var XgLiveLogger = /* @__PURE__ */ function() {
20688
20747
  var _temp4 = function() {
20689
20748
  if (Math.abs(Date.now() - _this9.log.playing.timestamp - timer) < 100 || Date.now() - _this9.log.playing.timestamp >= timer) {
20690
20749
  var _temp5 = function() {
20691
- if (!_this9.player.video) {
20750
+ if (!_this9.player || !_this9.player.video) {
20692
20751
  _this9.destroyFunc();
20693
20752
  } else {
20694
20753
  var _temp6 = function() {
@@ -20921,24 +20980,30 @@ var XgLiveLogger = /* @__PURE__ */ function() {
20921
20980
  this.player.off("bufferappend", this.handleBufferAppend);
20922
20981
  this.player.off("core_event", this.handleCoreEvent);
20923
20982
  this.player.off("degrade", this.handleDegrade);
20924
- this.clearPlayingInterval();
20925
- this.clearStallTimer();
20926
- this.clearPlayResultTimer();
20927
- clearTimeout(this.collectDownloadSpeedTimer);
20928
20983
  this._player = null;
20929
20984
  }
20930
- };
20931
- _proto2.handleUserLeave = function handleUserLeave() {
20932
- if (this.destroyed || !this.started) {
20933
- return;
20934
- }
20935
- this.destroyed = true;
20936
- this.updatePlayStopParams();
20937
- this.reportPlayStop();
20938
20985
  this.clearPlayingInterval();
20939
20986
  this.clearStallTimer();
20987
+ this.clearPlayResultTimer();
20940
20988
  clearTimeout(this.collectDownloadSpeedTimer);
20941
- this.removeWindowListener();
20989
+ };
20990
+ _proto2.handleUserLeave = function handleUserLeave() {
20991
+ try {
20992
+ var _this15 = this;
20993
+ if (_this15.destroyed || !_this15.started) {
20994
+ return Promise.resolve();
20995
+ }
20996
+ _this15.destroyed = true;
20997
+ return Promise.resolve(_this15.updatePlayStopParams()).then(function() {
20998
+ _this15.reportPlayStop();
20999
+ _this15.clearPlayingInterval();
21000
+ _this15.clearStallTimer();
21001
+ clearTimeout(_this15.collectDownloadSpeedTimer);
21002
+ _this15.removeWindowListener();
21003
+ });
21004
+ } catch (e3) {
21005
+ return Promise.reject(e3);
21006
+ }
20942
21007
  };
20943
21008
  _proto2.saveBuffered = function saveBuffered() {
20944
21009
  try {
@@ -20961,8 +21026,10 @@ var XgLiveLogger = /* @__PURE__ */ function() {
20961
21026
  }
20962
21027
  };
20963
21028
  _proto2.reportPlayStop = function reportPlayStop() {
20964
- this.log.play_stop.play_current_time = this.player.currentTime || this.log.playing.play_current_time;
20965
- this.saveBuffered();
21029
+ if (this.player) {
21030
+ this.log.play_stop.play_current_time = this.player.currentTime || this.log.playing.play_current_time;
21031
+ this.saveBuffered();
21032
+ }
20966
21033
  this.logmanager.push(this.log.play_stop, true);
20967
21034
  };
20968
21035
  _proto2.reportFirstframe = function reportFirstframe() {
@@ -20970,7 +21037,7 @@ var XgLiveLogger = /* @__PURE__ */ function() {
20970
21037
  return;
20971
21038
  }
20972
21039
  if (this.core) {
20973
- var _ref3 = this.core.getStats() || {}, fps = _ref3.fps;
21040
+ var _ref6 = this.core.getStats() || {}, fps = _ref6.fps;
20974
21041
  this.commonParams.fps = fps;
20975
21042
  }
20976
21043
  this.firstFrameViewed = true;
@@ -20989,47 +21056,79 @@ var XgLiveLogger = /* @__PURE__ */ function() {
20989
21056
  this.log.play_stop.is_stream_received = 1;
20990
21057
  };
20991
21058
  _proto2.updatePlayStopParams = function updatePlayStopParams() {
20992
- var timing = getResourceTiming(this._url);
20993
- var endTime = getCurrentTime();
20994
- this.playedTime = endTime - this.log.start_play.start_play_time;
20995
- var play_stop = this.log.play_stop;
20996
- Object.assign(play_stop, _objectSpread2({}, play_stop.stall_count === 0 && {
20997
- stall_time: 0
20998
- }));
20999
- if (this.inWaitingStart && endTime - this.inWaitingStart > 200) {
21000
- play_stop.stall_time += endTime - this.inWaitingStart;
21001
- }
21002
- this.inWaitingStart = 0;
21003
- Object.assign(play_stop, _objectSpread2({
21004
- stall_time_per_100sec: play_stop.stall_time / this.playedTime * 100,
21005
- // 计算百秒卡顿时长
21006
- stall_count_per_100sec: play_stop.stall_count * 1e3 / this.playedTime * 100
21007
- }, timing));
21008
- if (this.log.play_stop.stall_count_per_100sec === 0) {
21009
- this.log.play_stop.stall_time_per_100sec = 0;
21010
- }
21011
- if (this.log.play_stop.stall_time_per_100sec > 100 || this.log.play_stop.stall_time_per_100sec < 0) {
21012
- return;
21013
- }
21014
- if (this.log.playing.index) {
21015
- Object.assign(this.log.playing, _objectSpread2({
21016
- timestamp: getCurrentTime(),
21017
- is_last: 1
21018
- }, this.videoSize));
21019
- this.logmanager.push(this.log.playing, true);
21020
- } else {
21021
- this.log.play_stop.error_code = this.log.play_error.code;
21022
- this.log.play_stop.error_info = this.log.play_error.info;
21023
- }
21024
- endTime = getCurrentTime();
21025
- Object.assign(play_stop, _objectSpread2({
21026
- timestamp: endTime,
21027
- stop_time: endTime,
21028
- duration: this.playedTime / 1e3,
21029
- play_time: this.playedTime / 1e3
21030
- }, this.videoSize));
21031
- if (this.errorNumber === 0) {
21032
- play_stop.play_time_on_no_frame = play_stop.stop_time - this.log.start_play.start_play_time;
21059
+ try {
21060
+ var _this17$core;
21061
+ var _temp9 = function _temp92() {
21062
+ Object.assign(play_stop, _objectSpread2({
21063
+ timestamp: endTime,
21064
+ stop_time: endTime,
21065
+ duration: _this17.playedTime / 1e3,
21066
+ play_time: _this17.playedTime / 1e3
21067
+ }, _this17.videoSize));
21068
+ if (_this17.errorNumber === 0) {
21069
+ play_stop.play_time_on_no_frame = play_stop.stop_time - _this17.log.start_play.start_play_time;
21070
+ }
21071
+ };
21072
+ var _this17 = this;
21073
+ var timing = getResourceTiming(_this17._url);
21074
+ var endTime = getCurrentTime();
21075
+ _this17.playedTime = endTime - _this17.log.start_play.start_play_time;
21076
+ var play_stop = _this17.log.play_stop;
21077
+ Object.assign(play_stop, _objectSpread2({}, play_stop.stall_count === 0 && {
21078
+ stall_time: 0
21079
+ }));
21080
+ if (_this17.inWaitingStart && endTime - _this17.inWaitingStart > 200) {
21081
+ play_stop.stall_time += endTime - _this17.inWaitingStart;
21082
+ }
21083
+ _this17.inWaitingStart = 0;
21084
+ Object.assign(play_stop, _objectSpread2({
21085
+ stall_time_per_100sec: play_stop.stall_time / _this17.playedTime * 100,
21086
+ // 计算百秒卡顿时长
21087
+ stall_count_per_100sec: play_stop.stall_count * 1e3 / _this17.playedTime * 100
21088
+ }, timing));
21089
+ if (_this17.log.play_stop.stall_count_per_100sec === 0) {
21090
+ _this17.log.play_stop.stall_time_per_100sec = 0;
21091
+ }
21092
+ if (_this17.log.play_stop.stall_time_per_100sec > 100 || _this17.log.play_stop.stall_time_per_100sec < 0) {
21093
+ return Promise.resolve();
21094
+ }
21095
+ if (_this17.log.playing.index) {
21096
+ Object.assign(_this17.log.playing, _objectSpread2({
21097
+ timestamp: getCurrentTime(),
21098
+ is_last: 1
21099
+ }, _this17.videoSize));
21100
+ _this17.logmanager.push(_this17.log.playing, true);
21101
+ } else {
21102
+ _this17.log.play_stop.error_code = _this17.log.play_error.code;
21103
+ _this17.log.play_stop.error_info = _this17.log.play_error.info;
21104
+ }
21105
+ endTime = getCurrentTime();
21106
+ if ((_this17$core = _this17.core) === null || _this17$core === void 0 ? void 0 : _this17$core.getStats) {
21107
+ var _ref7 = _this17.core.getStats() || {}, totalReceivedByte = _ref7.totalReceivedByte, totalReceivedCost = _ref7.totalReceivedCost;
21108
+ Object.assign(_this17.log.play_stop, {
21109
+ totalReceivedByte,
21110
+ totalReceivedCost,
21111
+ totalAverageSpeed: totalReceivedByte * 8 / (totalReceivedCost / 1e3)
21112
+ // bps
21113
+ });
21114
+ }
21115
+ var _temp10 = function() {
21116
+ var _this17$core2;
21117
+ if ((_this17$core2 = _this17.core) === null || _this17$core2 === void 0 ? void 0 : _this17$core2.getStatsSnapshoot) {
21118
+ return Promise.resolve(_this17.core.getStatsSnapshoot()).then(function(_ref8) {
21119
+ var video = _ref8.video;
21120
+ var _ref9 = video || {}, packetsLost = _ref9.packetsLost, packetsReceived = _ref9.packetsReceived;
21121
+ Object.assign(play_stop, {
21122
+ packetsLost,
21123
+ packetsReceived,
21124
+ totalLostRate: packetsLost / (packetsLost + packetsReceived)
21125
+ });
21126
+ });
21127
+ }
21128
+ }();
21129
+ return Promise.resolve(_temp10 && _temp10.then ? _temp10.then(_temp9) : _temp9(_temp10));
21130
+ } catch (e3) {
21131
+ return Promise.reject(e3);
21033
21132
  }
21034
21133
  };
21035
21134
  _proto2.clearPlayingInterval = function clearPlayingInterval() {
@@ -21895,9 +21994,9 @@ class Logger extends Plugin {
21895
21994
  user_id: this._userId,
21896
21995
  device_id: this._deviceId,
21897
21996
  ext: {
21898
- veplayer_version: "2.4.0-rc.3",
21899
- flv_version: "3.0.18-alpha.5",
21900
- hls_version: "3.0.17",
21997
+ veplayer_version: "2.4.0-rc.4",
21998
+ flv_version: "3.0.19-rc.0",
21999
+ hls_version: "3.0.19-rc.0",
21901
22000
  rts_version: "0.2.1-alpha.0"
21902
22001
  }
21903
22002
  });
@@ -22195,8 +22294,9 @@ const getDrmStrategy = async (options, player) => {
22195
22294
  const getAbrStrategy = async (options) => {
22196
22295
  var _a, _b;
22197
22296
  const streamType = options.url && getStreamType(options.url);
22198
- if (streamType === "rtm")
22297
+ if (streamType === "rtm") {
22199
22298
  return {};
22299
+ }
22200
22300
  const abrOptions = streamType === "flv" ? (_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.abr : (_b = options == null ? void 0 : options.hls) == null ? void 0 : _b.abr;
22201
22301
  if (!abrOptions) {
22202
22302
  return {};
@@ -22244,6 +22344,23 @@ class VePlayerLive extends VePlayerBase {
22244
22344
  constructor(options) {
22245
22345
  super(options);
22246
22346
  }
22347
+ /** {zh}
22348
+ * @brief 获取已经播放的时间
22349
+ */
22350
+ get playTime() {
22351
+ var _a, _b, _c, _d;
22352
+ if (!((_b = (_a = this._player) == null ? void 0 : _a.played) == null ? void 0 : _b.length)) {
22353
+ return 0;
22354
+ }
22355
+ const length = this._player.played.length;
22356
+ let time = 0;
22357
+ for (let index = 0; index < length; index++) {
22358
+ const start = (_c = this._player) == null ? void 0 : _c.played.start(index);
22359
+ const end = (_d = this._player) == null ? void 0 : _d.played.end(index);
22360
+ time += end - start;
22361
+ }
22362
+ return time;
22363
+ }
22247
22364
  /** {zh}
22248
22365
  * @brief 调用此方法开启直播日志上报。
22249
22366
  */
@@ -22286,13 +22403,33 @@ class VePlayerLive extends VePlayerBase {
22286
22403
  var _a;
22287
22404
  (_a = this._player.plugins) == null ? void 0 : _a.infopanel.close();
22288
22405
  }
22406
+ /** {zh}
22407
+ * @brief 打开 Abr
22408
+ */
22289
22409
  openAbr() {
22290
- var _a, _b;
22291
- (_b = (_a = this._player.plugins) == null ? void 0 : _a.abr) == null ? void 0 : _b.switchAbr(true);
22410
+ var _a, _b, _c, _d;
22411
+ const streamType = this.url && getStreamType(this.url);
22412
+ if (streamType === "flv") {
22413
+ (_b = (_a = this._player.plugins) == null ? void 0 : _a.abr) == null ? void 0 : _b.switchAbr(true);
22414
+ return;
22415
+ }
22416
+ if (streamType === "hls") {
22417
+ (_d = (_c = this._player.plugins) == null ? void 0 : _c.hlsabr) == null ? void 0 : _d.switchAbr(true);
22418
+ }
22292
22419
  }
22420
+ /** {zh}
22421
+ * @brief 关闭 Abr
22422
+ */
22293
22423
  closeAbr() {
22294
- var _a, _b;
22295
- (_b = (_a = this._player.plugins) == null ? void 0 : _a.abr) == null ? void 0 : _b.switchAbr(false);
22424
+ var _a, _b, _c, _d;
22425
+ const streamType = this.url && getStreamType(this.url);
22426
+ if (streamType === "flv") {
22427
+ (_b = (_a = this._player.plugins) == null ? void 0 : _a.abr) == null ? void 0 : _b.switchAbr(false);
22428
+ return;
22429
+ }
22430
+ if (streamType === "hls") {
22431
+ (_d = (_c = this._player.plugins) == null ? void 0 : _c.hlsabr) == null ? void 0 : _d.switchAbr(false);
22432
+ }
22296
22433
  }
22297
22434
  /** {zh}
22298
22435
  * @brief 调用此方法更新 DRM 鉴权配置。
@@ -22302,56 +22439,48 @@ class VePlayerLive extends VePlayerBase {
22302
22439
  var _a, _b, _c;
22303
22440
  (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.drm) == null ? void 0 : _c.updateDrmConfig(config);
22304
22441
  }
22305
- switchAbr({ enable, bitrate }) {
22442
+ /** {zh}
22443
+ * @brief 切换 flv Abr
22444
+ * @param options 切换 Abr 的配置。
22445
+ * @returns
22446
+ */
22447
+ switchAbr(options) {
22306
22448
  var _a, _b;
22307
22449
  if (!((_a = this._player.plugins) == null ? void 0 : _a.abr)) {
22308
22450
  return;
22309
22451
  }
22310
- if (typeof bitrate !== "undefined") {
22311
- const url = this._player.plugins.abr.config.urls[bitrate];
22452
+ if (typeof (options == null ? void 0 : options.bitrate) !== "undefined") {
22453
+ const url = this._player.plugins.abr.config.urls[options.bitrate];
22312
22454
  if (!url) {
22313
22455
  return;
22314
22456
  }
22315
22457
  this.switch(url, { seamless: true });
22316
- this._player.plugins.abr.bitrate = bitrate;
22317
- }
22318
- if (typeof enable !== "undefined") {
22319
- (_b = this._player.plugins) == null ? void 0 : _b.abr.switchAbr(enable);
22320
- }
22321
- }
22322
- async switch(target, options) {
22323
- var _a, _b, _c;
22324
- const { abr, ...rest } = options ?? {};
22325
- if (abr) {
22326
- (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.abr) == null ? void 0 : _c.updateConfig(abr);
22327
- }
22328
- return super.switch(target, rest);
22329
- }
22330
- getPlayTime() {
22331
- var _a, _b, _c, _d;
22332
- if (!((_b = (_a = this._player) == null ? void 0 : _a.played) == null ? void 0 : _b.length)) {
22333
- return 0;
22458
+ this._player.plugins.abr.bitrate = options.bitrate;
22334
22459
  }
22335
- const length = this._player.played.length;
22336
- let time = 0;
22337
- for (let index = 0; index < length; index++) {
22338
- const start = (_c = this._player) == null ? void 0 : _c.played.start(index);
22339
- const end = (_d = this._player) == null ? void 0 : _d.played.end(index);
22340
- time += end - start;
22460
+ if (typeof (options == null ? void 0 : options.enable) !== "undefined") {
22461
+ (_b = this._player.plugins) == null ? void 0 : _b.abr.switchAbr(options.enable);
22341
22462
  }
22342
- return time;
22343
- }
22344
- getPlayerVersion() {
22345
- return "2.4.0-rc.3";
22346
22463
  }
22464
+ /** {zh}
22465
+ * @brief 获取 RTM 的网络相关信息
22466
+ * @returns
22467
+ */
22347
22468
  getRTMNetWorkInfo() {
22348
22469
  var _a, _b, _c;
22349
22470
  return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getNetWorkInfo();
22350
22471
  }
22472
+ /** {zh}
22473
+ * @brief 获取 RTM 播放信息
22474
+ * @returns
22475
+ */
22351
22476
  async getRTMStats() {
22352
- var _a;
22353
- return (_a = this._player) == null ? void 0 : _a.plugins.rts.getStatsSnapshoot();
22477
+ var _a, _b, _c;
22478
+ return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getStatsSnapshoot();
22354
22479
  }
22480
+ /** {zh}
22481
+ * @brief 获取 FLV 播放信息
22482
+ * @returns
22483
+ */
22355
22484
  getFLVStats() {
22356
22485
  var _a, _b, _c;
22357
22486
  return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.flv) == null ? void 0 : _c.getStats();