@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.
@@ -6159,7 +6159,24 @@ var checkVideoFrameCallback = function checkVideoFrameCallback2() {
6159
6159
  };
6160
6160
  var VideoStallObserver = /* @__PURE__ */ function() {
6161
6161
  function VideoStallObserver2() {
6162
+ var _this = this;
6162
6163
  _classCallCheck$3(this, VideoStallObserver2);
6164
+ _defineProperty$2(this, "_handleVisibilityChange", function() {
6165
+ if (document.visibilityState === "hidden") {
6166
+ _this._framePause();
6167
+ }
6168
+ });
6169
+ _defineProperty$2(this, "_framePause", function() {
6170
+ if (_this._prePts) {
6171
+ var current = performance.now();
6172
+ var delta = current - _this._prePts;
6173
+ _this._stallList.push({
6174
+ playTime: current,
6175
+ timeUpdateInterval: Math.round(delta)
6176
+ });
6177
+ _this._prePts = void 0;
6178
+ }
6179
+ });
6163
6180
  this._removeHandler = void 0;
6164
6181
  this._remotePlayPauseHandler = void 0;
6165
6182
  this._prePts = void 0;
@@ -6180,20 +6197,20 @@ var VideoStallObserver = /* @__PURE__ */ function() {
6180
6197
  _createClass$3(VideoStallObserver2, [{
6181
6198
  key: "start",
6182
6199
  value: function start(player) {
6183
- var _this = this;
6200
+ var _this2 = this;
6184
6201
  this._player = player;
6185
6202
  if (this._support100msStall) {
6186
6203
  if (player) {
6187
6204
  this._requestVideoFrameCallbackTimer = player.requestVideoFrameCallback(this._onVideoRefresh.bind(this));
6188
6205
  this._removeHandler = function() {
6189
- if (_this._requestVideoFrameCallbackTimer) {
6190
- player.cancelVideoFrameCallback(_this._requestVideoFrameCallbackTimer);
6206
+ if (_this2._requestVideoFrameCallbackTimer) {
6207
+ player.cancelVideoFrameCallback(_this2._requestVideoFrameCallbackTimer);
6191
6208
  }
6192
6209
  };
6193
6210
  }
6194
6211
  } else {
6195
6212
  var handle = function handle2() {
6196
- return _this._onVideoTimeupdate(player);
6213
+ return _this2._onVideoTimeupdate(player);
6197
6214
  };
6198
6215
  player.addEventListener("timeupdate", handle);
6199
6216
  this._removeHandler = function() {
@@ -6201,17 +6218,19 @@ var VideoStallObserver = /* @__PURE__ */ function() {
6201
6218
  };
6202
6219
  }
6203
6220
  var handlePause = function handlePause2() {
6204
- return _this._onVideoPause();
6221
+ return _this2._onVideoPause();
6205
6222
  };
6206
6223
  player.addEventListener("pause", handlePause);
6207
6224
  var handlePlay = function handlePlay2() {
6208
- return _this._onVideoPlay();
6225
+ return _this2._onVideoPlay();
6209
6226
  };
6210
6227
  player.addEventListener("play", handlePlay);
6211
6228
  this._remotePlayPauseHandler = function() {
6212
6229
  player.removeEventListener("pause", handlePause);
6213
6230
  player.removeEventListener("play", handlePlay);
6214
6231
  };
6232
+ document.addEventListener("visibilitychange", this._handleVisibilityChange);
6233
+ document.addEventListener("pagehide", this._framePause());
6215
6234
  }
6216
6235
  }, {
6217
6236
  key: "stop",
@@ -6229,6 +6248,8 @@ var VideoStallObserver = /* @__PURE__ */ function() {
6229
6248
  delete this._prePts;
6230
6249
  this._videoInWaiting100ms = false;
6231
6250
  this._videoInWaiting500ms = false;
6251
+ document.removeEventListener("visibilitychange", this._handleVisibilityChange);
6252
+ document.removeEventListener("pagehide", this._framePause());
6232
6253
  }
6233
6254
  }, {
6234
6255
  key: "destroy",
@@ -6238,7 +6259,7 @@ var VideoStallObserver = /* @__PURE__ */ function() {
6238
6259
  }, {
6239
6260
  key: "getStallInfo",
6240
6261
  value: function getStallInfo(_ref) {
6241
- var _this2 = this;
6262
+ var _this3 = this;
6242
6263
  var interval = _ref.interval, frameRateReceived = _ref.frameRateReceived, frameRateDecoded = _ref.frameRateDecoded, bitrate = _ref.bitrate;
6243
6264
  var stallInfo = {
6244
6265
  pts: 0,
@@ -6252,7 +6273,7 @@ var VideoStallObserver = /* @__PURE__ */ function() {
6252
6273
  },
6253
6274
  pauseDuration: this._getPauseDuration()
6254
6275
  };
6255
- if (this._stallList) {
6276
+ if (this._stallList && document.visibilityState === "visible" && !this._isPaused) {
6256
6277
  var poorNetworkInSafari = (isSafari() || isFirefox()) && (bitrate === 0 || (frameRateDecoded || Infinity) <= 1 || (frameRateReceived || Infinity) <= 1);
6257
6278
  if (poorNetworkInSafari || this._stallList.length === 0) {
6258
6279
  stallInfo.stall.stallDuration500ms = interval;
@@ -6269,27 +6290,27 @@ var VideoStallObserver = /* @__PURE__ */ function() {
6269
6290
  this._stallList.forEach(function(frameRecord, idx) {
6270
6291
  var timeUpdateInterval = frameRecord.timeUpdateInterval, playTime = frameRecord.playTime;
6271
6292
  var stallDuration = timeUpdateInterval;
6272
- if (idx === 0 && (_this2._videoInWaiting100ms || _this2._videoInWaiting500ms)) {
6293
+ if (idx === 0 && (_this3._videoInWaiting100ms || _this3._videoInWaiting500ms)) {
6273
6294
  stallDuration = Math.round(timeUpdateInterval % interval);
6274
6295
  }
6275
- if (timeUpdateInterval > _this2._stallTimeThreshold.stall500ms) {
6296
+ if (timeUpdateInterval > _this3._stallTimeThreshold.stall500ms) {
6276
6297
  stallInfo.stall.stallDuration500ms += stallDuration;
6277
- if (!_this2._videoInWaiting500ms) {
6298
+ if (!_this3._videoInWaiting500ms) {
6278
6299
  stallInfo.stall.stallCount500ms++;
6279
6300
  }
6280
- _this2._videoInWaiting500ms = true;
6301
+ _this3._videoInWaiting500ms = true;
6281
6302
  } else {
6282
- _this2._videoInWaiting500ms = false;
6303
+ _this3._videoInWaiting500ms = false;
6283
6304
  }
6284
- if (_this2._support100msStall) {
6285
- if (timeUpdateInterval > _this2._stallTimeThreshold.stall100ms) {
6305
+ if (_this3._support100msStall) {
6306
+ if (timeUpdateInterval > _this3._stallTimeThreshold.stall100ms) {
6286
6307
  stallInfo.stall.stallDuration100ms += stallDuration;
6287
- if (!_this2._videoInWaiting100ms) {
6308
+ if (!_this3._videoInWaiting100ms) {
6288
6309
  stallInfo.stall.stallCount100ms++;
6289
6310
  }
6290
- _this2._videoInWaiting100ms = true;
6311
+ _this3._videoInWaiting100ms = true;
6291
6312
  } else {
6292
- _this2._videoInWaiting100ms = false;
6313
+ _this3._videoInWaiting100ms = false;
6293
6314
  }
6294
6315
  }
6295
6316
  stallInfo.pts = playTime;
@@ -6328,6 +6349,7 @@ var VideoStallObserver = /* @__PURE__ */ function() {
6328
6349
  value: function _onVideoPause() {
6329
6350
  this._isPaused = true;
6330
6351
  this._pauseStart = Date.now();
6352
+ this._framePause();
6331
6353
  }
6332
6354
  }, {
6333
6355
  key: "_onVideoPlay",
@@ -6763,7 +6785,6 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
6763
6785
  });
6764
6786
  _defineProperty$2(_assertThisInitialized$1(_this), "_onLoadedData", function() {
6765
6787
  logger.log("loadeddata emit");
6766
- _this._startRtcReport();
6767
6788
  _this.getStatsSnapshoot().then(function(snap) {
6768
6789
  _this.emit(EVENT.METADATA_PARSED, {
6769
6790
  type: "video",
@@ -6954,6 +6975,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
6954
6975
  elapsed: Date.now() - _this3._rctConnectStartTs
6955
6976
  });
6956
6977
  _this3._checkStatsError();
6978
+ _this3._startRtcReport();
6957
6979
  }
6958
6980
  });
6959
6981
  }
@@ -7209,6 +7231,7 @@ var Rts = /* @__PURE__ */ function(_EventEmitter) {
7209
7231
  key: "_startRtcReport",
7210
7232
  value: function _startRtcReport() {
7211
7233
  var _this6 = this;
7234
+ this._stopRtcReport();
7212
7235
  this._rtcReportTimer = setInterval(/* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee5() {
7213
7236
  var _yield$Promise$all, _yield$Promise$all2, curAudioStats, curVideoStats, _this6$_audioStallObs, _this6$_videoStallObs, _this6$_networkQualit, _this6$_networkQualit2, audioStats, videoStats, audioStallInfo, videoStallInfo, _ref4, _ref5, quality, qualityInfo, targetDelay;
7214
7237
  return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
@@ -7498,7 +7521,7 @@ var RtsPlugin = /* @__PURE__ */ function(_BasePlugin) {
7498
7521
  }, {
7499
7522
  key: "version",
7500
7523
  get: function get() {
7501
- return "0.2.1-alpha.29";
7524
+ return "0.2.1-alpha.30";
7502
7525
  }
7503
7526
  }, {
7504
7527
  key: "beforePlayerInit",