@byteplus/veplayer-plugin 2.8.0-rc.1 → 2.8.0-rc.3

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.
@@ -34864,7 +34864,24 @@ var checkVideoFrameCallback = function checkVideoFrameCallback2() {
34864
34864
  };
34865
34865
  var VideoStallObserver = /* @__PURE__ */ function() {
34866
34866
  function VideoStallObserver2() {
34867
+ var _this = this;
34867
34868
  _classCallCheck$j(this, VideoStallObserver2);
34869
+ _defineProperty$g(this, "_handleVisibilityChange", function() {
34870
+ if (document.visibilityState === "hidden") {
34871
+ _this._framePause();
34872
+ }
34873
+ });
34874
+ _defineProperty$g(this, "_framePause", function() {
34875
+ if (_this._prePts) {
34876
+ var current = performance.now();
34877
+ var delta = current - _this._prePts;
34878
+ _this._stallList.push({
34879
+ playTime: current,
34880
+ timeUpdateInterval: Math.round(delta)
34881
+ });
34882
+ _this._prePts = void 0;
34883
+ }
34884
+ });
34868
34885
  this._removeHandler = void 0;
34869
34886
  this._remotePlayPauseHandler = void 0;
34870
34887
  this._prePts = void 0;
@@ -34885,20 +34902,20 @@ var VideoStallObserver = /* @__PURE__ */ function() {
34885
34902
  _createClass$j(VideoStallObserver2, [{
34886
34903
  key: "start",
34887
34904
  value: function start(player) {
34888
- var _this = this;
34905
+ var _this2 = this;
34889
34906
  this._player = player;
34890
34907
  if (this._support100msStall) {
34891
34908
  if (player) {
34892
34909
  this._requestVideoFrameCallbackTimer = player.requestVideoFrameCallback(this._onVideoRefresh.bind(this));
34893
34910
  this._removeHandler = function() {
34894
- if (_this._requestVideoFrameCallbackTimer) {
34895
- player.cancelVideoFrameCallback(_this._requestVideoFrameCallbackTimer);
34911
+ if (_this2._requestVideoFrameCallbackTimer) {
34912
+ player.cancelVideoFrameCallback(_this2._requestVideoFrameCallbackTimer);
34896
34913
  }
34897
34914
  };
34898
34915
  }
34899
34916
  } else {
34900
34917
  var handle = function handle2() {
34901
- return _this._onVideoTimeupdate(player);
34918
+ return _this2._onVideoTimeupdate(player);
34902
34919
  };
34903
34920
  player.addEventListener("timeupdate", handle);
34904
34921
  this._removeHandler = function() {
@@ -34906,17 +34923,19 @@ var VideoStallObserver = /* @__PURE__ */ function() {
34906
34923
  };
34907
34924
  }
34908
34925
  var handlePause = function handlePause2() {
34909
- return _this._onVideoPause();
34926
+ return _this2._onVideoPause();
34910
34927
  };
34911
34928
  player.addEventListener("pause", handlePause);
34912
34929
  var handlePlay = function handlePlay2() {
34913
- return _this._onVideoPlay();
34930
+ return _this2._onVideoPlay();
34914
34931
  };
34915
34932
  player.addEventListener("play", handlePlay);
34916
34933
  this._remotePlayPauseHandler = function() {
34917
34934
  player.removeEventListener("pause", handlePause);
34918
34935
  player.removeEventListener("play", handlePlay);
34919
34936
  };
34937
+ document.addEventListener("visibilitychange", this._handleVisibilityChange);
34938
+ document.addEventListener("pagehide", this._framePause());
34920
34939
  }
34921
34940
  }, {
34922
34941
  key: "stop",
@@ -34934,6 +34953,8 @@ var VideoStallObserver = /* @__PURE__ */ function() {
34934
34953
  delete this._prePts;
34935
34954
  this._videoInWaiting100ms = false;
34936
34955
  this._videoInWaiting500ms = false;
34956
+ document.removeEventListener("visibilitychange", this._handleVisibilityChange);
34957
+ document.removeEventListener("pagehide", this._framePause());
34937
34958
  }
34938
34959
  }, {
34939
34960
  key: "destroy",
@@ -34943,7 +34964,7 @@ var VideoStallObserver = /* @__PURE__ */ function() {
34943
34964
  }, {
34944
34965
  key: "getStallInfo",
34945
34966
  value: function getStallInfo(_ref6) {
34946
- var _this2 = this;
34967
+ var _this3 = this;
34947
34968
  var interval = _ref6.interval, frameRateReceived = _ref6.frameRateReceived, frameRateDecoded = _ref6.frameRateDecoded, bitrate = _ref6.bitrate;
34948
34969
  var stallInfo = {
34949
34970
  pts: 0,
@@ -34957,7 +34978,7 @@ var VideoStallObserver = /* @__PURE__ */ function() {
34957
34978
  },
34958
34979
  pauseDuration: this._getPauseDuration()
34959
34980
  };
34960
- if (this._stallList) {
34981
+ if (this._stallList && document.visibilityState === "visible" && !this._isPaused) {
34961
34982
  var poorNetworkInSafari = (isSafari$1() || isFirefox$2()) && (bitrate === 0 || (frameRateDecoded || Infinity) <= 1 || (frameRateReceived || Infinity) <= 1);
34962
34983
  if (poorNetworkInSafari || this._stallList.length === 0) {
34963
34984
  stallInfo.stall.stallDuration500ms = interval;
@@ -34974,27 +34995,27 @@ var VideoStallObserver = /* @__PURE__ */ function() {
34974
34995
  this._stallList.forEach(function(frameRecord, idx) {
34975
34996
  var timeUpdateInterval = frameRecord.timeUpdateInterval, playTime = frameRecord.playTime;
34976
34997
  var stallDuration = timeUpdateInterval;
34977
- if (idx === 0 && (_this2._videoInWaiting100ms || _this2._videoInWaiting500ms)) {
34998
+ if (idx === 0 && (_this3._videoInWaiting100ms || _this3._videoInWaiting500ms)) {
34978
34999
  stallDuration = Math.round(timeUpdateInterval % interval);
34979
35000
  }
34980
- if (timeUpdateInterval > _this2._stallTimeThreshold.stall500ms) {
35001
+ if (timeUpdateInterval > _this3._stallTimeThreshold.stall500ms) {
34981
35002
  stallInfo.stall.stallDuration500ms += stallDuration;
34982
- if (!_this2._videoInWaiting500ms) {
35003
+ if (!_this3._videoInWaiting500ms) {
34983
35004
  stallInfo.stall.stallCount500ms++;
34984
35005
  }
34985
- _this2._videoInWaiting500ms = true;
35006
+ _this3._videoInWaiting500ms = true;
34986
35007
  } else {
34987
- _this2._videoInWaiting500ms = false;
35008
+ _this3._videoInWaiting500ms = false;
34988
35009
  }
34989
- if (_this2._support100msStall) {
34990
- if (timeUpdateInterval > _this2._stallTimeThreshold.stall100ms) {
35010
+ if (_this3._support100msStall) {
35011
+ if (timeUpdateInterval > _this3._stallTimeThreshold.stall100ms) {
34991
35012
  stallInfo.stall.stallDuration100ms += stallDuration;
34992
- if (!_this2._videoInWaiting100ms) {
35013
+ if (!_this3._videoInWaiting100ms) {
34993
35014
  stallInfo.stall.stallCount100ms++;
34994
35015
  }
34995
- _this2._videoInWaiting100ms = true;
35016
+ _this3._videoInWaiting100ms = true;
34996
35017
  } else {
34997
- _this2._videoInWaiting100ms = false;
35018
+ _this3._videoInWaiting100ms = false;
34998
35019
  }
34999
35020
  }
35000
35021
  stallInfo.pts = playTime;
@@ -35033,6 +35054,7 @@ var VideoStallObserver = /* @__PURE__ */ function() {
35033
35054
  value: function _onVideoPause() {
35034
35055
  this._isPaused = true;
35035
35056
  this._pauseStart = Date.now();
35057
+ this._framePause();
35036
35058
  }
35037
35059
  }, {
35038
35060
  key: "_onVideoPlay",
@@ -35468,7 +35490,6 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
35468
35490
  });
35469
35491
  _defineProperty$g(_assertThisInitialized$e(_this), "_onLoadedData", function() {
35470
35492
  logger$a.log("loadeddata emit");
35471
- _this._startRtcReport();
35472
35493
  _this.getStatsSnapshoot().then(function(snap) {
35473
35494
  _this.emit(EVENT$2.METADATA_PARSED, {
35474
35495
  type: "video",
@@ -35659,6 +35680,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
35659
35680
  elapsed: Date.now() - _this3._rctConnectStartTs
35660
35681
  });
35661
35682
  _this3._checkStatsError();
35683
+ _this3._startRtcReport();
35662
35684
  }
35663
35685
  });
35664
35686
  }
@@ -35914,6 +35936,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
35914
35936
  key: "_startRtcReport",
35915
35937
  value: function _startRtcReport() {
35916
35938
  var _this6 = this;
35939
+ this._stopRtcReport();
35917
35940
  this._rtcReportTimer = setInterval(/* @__PURE__ */ _asyncToGenerator$a(/* @__PURE__ */ _regeneratorRuntime$a().mark(function _callee5() {
35918
35941
  var _yield$Promise$all, _yield$Promise$all2, curAudioStats, curVideoStats, _this6$_audioStallObs, _this6$_videoStallObs, _this6$_networkQualit, _this6$_networkQualit2, audioStats, videoStats, audioStallInfo, videoStallInfo, _ref42, _ref52, quality, qualityInfo, targetDelay;
35919
35942
  return _regeneratorRuntime$a().wrap(function _callee5$(_context5) {
@@ -36203,7 +36226,7 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
36203
36226
  }, {
36204
36227
  key: "version",
36205
36228
  get: function get4() {
36206
- return "0.2.1-alpha.29";
36229
+ return "0.2.1-alpha.30";
36207
36230
  }
36208
36231
  }, {
36209
36232
  key: "beforePlayerInit",