@byteplus/veplayer-plugin 2.8.0-rc.0 → 2.8.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byteplus/veplayer-plugin",
3
- "version": "2.8.0-rc.0",
3
+ "version": "2.8.0-rc.2",
4
4
  "main": "./umd/index.production.js",
5
5
  "module": "./esm/index.production.js",
6
6
  "browser": "./umd/index.production.js",
package/umd/index.d.ts CHANGED
@@ -8,3 +8,5 @@ export const timeShift: any;
8
8
  export const ad: any;
9
9
  export const drm: any;
10
10
  export const abr: any;
11
+ export const strategy: any;
12
+ export const strategyRtmAdaptiveBuffer: any;
@@ -6163,7 +6163,24 @@
6163
6163
  };
6164
6164
  var VideoStallObserver = /* @__PURE__ */ function() {
6165
6165
  function VideoStallObserver2() {
6166
+ var _this = this;
6166
6167
  _classCallCheck$3(this, VideoStallObserver2);
6168
+ _defineProperty$2(this, "_handleVisibilityChange", function() {
6169
+ if (document.visibilityState === "hidden") {
6170
+ _this._framePause();
6171
+ }
6172
+ });
6173
+ _defineProperty$2(this, "_framePause", function() {
6174
+ if (_this._prePts) {
6175
+ var current = performance.now();
6176
+ var delta = current - _this._prePts;
6177
+ _this._stallList.push({
6178
+ playTime: current,
6179
+ timeUpdateInterval: Math.round(delta)
6180
+ });
6181
+ _this._prePts = void 0;
6182
+ }
6183
+ });
6167
6184
  this._removeHandler = void 0;
6168
6185
  this._remotePlayPauseHandler = void 0;
6169
6186
  this._prePts = void 0;
@@ -6184,20 +6201,20 @@
6184
6201
  _createClass$3(VideoStallObserver2, [{
6185
6202
  key: "start",
6186
6203
  value: function start(player) {
6187
- var _this = this;
6204
+ var _this2 = this;
6188
6205
  this._player = player;
6189
6206
  if (this._support100msStall) {
6190
6207
  if (player) {
6191
6208
  this._requestVideoFrameCallbackTimer = player.requestVideoFrameCallback(this._onVideoRefresh.bind(this));
6192
6209
  this._removeHandler = function() {
6193
- if (_this._requestVideoFrameCallbackTimer) {
6194
- player.cancelVideoFrameCallback(_this._requestVideoFrameCallbackTimer);
6210
+ if (_this2._requestVideoFrameCallbackTimer) {
6211
+ player.cancelVideoFrameCallback(_this2._requestVideoFrameCallbackTimer);
6195
6212
  }
6196
6213
  };
6197
6214
  }
6198
6215
  } else {
6199
6216
  var handle = function handle2() {
6200
- return _this._onVideoTimeupdate(player);
6217
+ return _this2._onVideoTimeupdate(player);
6201
6218
  };
6202
6219
  player.addEventListener("timeupdate", handle);
6203
6220
  this._removeHandler = function() {
@@ -6205,17 +6222,19 @@
6205
6222
  };
6206
6223
  }
6207
6224
  var handlePause = function handlePause2() {
6208
- return _this._onVideoPause();
6225
+ return _this2._onVideoPause();
6209
6226
  };
6210
6227
  player.addEventListener("pause", handlePause);
6211
6228
  var handlePlay = function handlePlay2() {
6212
- return _this._onVideoPlay();
6229
+ return _this2._onVideoPlay();
6213
6230
  };
6214
6231
  player.addEventListener("play", handlePlay);
6215
6232
  this._remotePlayPauseHandler = function() {
6216
6233
  player.removeEventListener("pause", handlePause);
6217
6234
  player.removeEventListener("play", handlePlay);
6218
6235
  };
6236
+ document.addEventListener("visibilitychange", this._handleVisibilityChange);
6237
+ document.addEventListener("pagehide", this._framePause());
6219
6238
  }
6220
6239
  }, {
6221
6240
  key: "stop",
@@ -6233,6 +6252,8 @@
6233
6252
  delete this._prePts;
6234
6253
  this._videoInWaiting100ms = false;
6235
6254
  this._videoInWaiting500ms = false;
6255
+ document.removeEventListener("visibilitychange", this._handleVisibilityChange);
6256
+ document.removeEventListener("pagehide", this._framePause());
6236
6257
  }
6237
6258
  }, {
6238
6259
  key: "destroy",
@@ -6242,7 +6263,7 @@
6242
6263
  }, {
6243
6264
  key: "getStallInfo",
6244
6265
  value: function getStallInfo(_ref) {
6245
- var _this2 = this;
6266
+ var _this3 = this;
6246
6267
  var interval = _ref.interval, frameRateReceived = _ref.frameRateReceived, frameRateDecoded = _ref.frameRateDecoded, bitrate = _ref.bitrate;
6247
6268
  var stallInfo = {
6248
6269
  pts: 0,
@@ -6256,7 +6277,7 @@
6256
6277
  },
6257
6278
  pauseDuration: this._getPauseDuration()
6258
6279
  };
6259
- if (this._stallList) {
6280
+ if (this._stallList && document.visibilityState === "visible" && !this._isPaused) {
6260
6281
  var poorNetworkInSafari = (isSafari() || isFirefox()) && (bitrate === 0 || (frameRateDecoded || Infinity) <= 1 || (frameRateReceived || Infinity) <= 1);
6261
6282
  if (poorNetworkInSafari || this._stallList.length === 0) {
6262
6283
  stallInfo.stall.stallDuration500ms = interval;
@@ -6273,27 +6294,27 @@
6273
6294
  this._stallList.forEach(function(frameRecord, idx) {
6274
6295
  var timeUpdateInterval = frameRecord.timeUpdateInterval, playTime = frameRecord.playTime;
6275
6296
  var stallDuration = timeUpdateInterval;
6276
- if (idx === 0 && (_this2._videoInWaiting100ms || _this2._videoInWaiting500ms)) {
6297
+ if (idx === 0 && (_this3._videoInWaiting100ms || _this3._videoInWaiting500ms)) {
6277
6298
  stallDuration = Math.round(timeUpdateInterval % interval);
6278
6299
  }
6279
- if (timeUpdateInterval > _this2._stallTimeThreshold.stall500ms) {
6300
+ if (timeUpdateInterval > _this3._stallTimeThreshold.stall500ms) {
6280
6301
  stallInfo.stall.stallDuration500ms += stallDuration;
6281
- if (!_this2._videoInWaiting500ms) {
6302
+ if (!_this3._videoInWaiting500ms) {
6282
6303
  stallInfo.stall.stallCount500ms++;
6283
6304
  }
6284
- _this2._videoInWaiting500ms = true;
6305
+ _this3._videoInWaiting500ms = true;
6285
6306
  } else {
6286
- _this2._videoInWaiting500ms = false;
6307
+ _this3._videoInWaiting500ms = false;
6287
6308
  }
6288
- if (_this2._support100msStall) {
6289
- if (timeUpdateInterval > _this2._stallTimeThreshold.stall100ms) {
6309
+ if (_this3._support100msStall) {
6310
+ if (timeUpdateInterval > _this3._stallTimeThreshold.stall100ms) {
6290
6311
  stallInfo.stall.stallDuration100ms += stallDuration;
6291
- if (!_this2._videoInWaiting100ms) {
6312
+ if (!_this3._videoInWaiting100ms) {
6292
6313
  stallInfo.stall.stallCount100ms++;
6293
6314
  }
6294
- _this2._videoInWaiting100ms = true;
6315
+ _this3._videoInWaiting100ms = true;
6295
6316
  } else {
6296
- _this2._videoInWaiting100ms = false;
6317
+ _this3._videoInWaiting100ms = false;
6297
6318
  }
6298
6319
  }
6299
6320
  stallInfo.pts = playTime;
@@ -6332,6 +6353,7 @@
6332
6353
  value: function _onVideoPause() {
6333
6354
  this._isPaused = true;
6334
6355
  this._pauseStart = Date.now();
6356
+ this._framePause();
6335
6357
  }
6336
6358
  }, {
6337
6359
  key: "_onVideoPlay",
@@ -6767,7 +6789,6 @@
6767
6789
  });
6768
6790
  _defineProperty$2(_assertThisInitialized$1(_this), "_onLoadedData", function() {
6769
6791
  logger.log("loadeddata emit");
6770
- _this._startRtcReport();
6771
6792
  _this.getStatsSnapshoot().then(function(snap) {
6772
6793
  _this.emit(EVENT.METADATA_PARSED, {
6773
6794
  type: "video",
@@ -6958,6 +6979,7 @@
6958
6979
  elapsed: Date.now() - _this3._rctConnectStartTs
6959
6980
  });
6960
6981
  _this3._checkStatsError();
6982
+ _this3._startRtcReport();
6961
6983
  }
6962
6984
  });
6963
6985
  }
@@ -7213,6 +7235,7 @@
7213
7235
  key: "_startRtcReport",
7214
7236
  value: function _startRtcReport() {
7215
7237
  var _this6 = this;
7238
+ this._stopRtcReport();
7216
7239
  this._rtcReportTimer = setInterval(/* @__PURE__ */ _asyncToGenerator$1(/* @__PURE__ */ _regeneratorRuntime$1().mark(function _callee5() {
7217
7240
  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;
7218
7241
  return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
@@ -7502,7 +7525,7 @@
7502
7525
  }, {
7503
7526
  key: "version",
7504
7527
  get: function get() {
7505
- return "0.2.1-alpha.29";
7528
+ return "0.2.1-alpha.30";
7506
7529
  }
7507
7530
  }, {
7508
7531
  key: "beforePlayerInit",