@byteplus/veplayer 2.4.1-rc.1 → 2.4.2-rc.0

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.
@@ -1312,7 +1312,7 @@ var VERSION_REG = {
1312
1312
  android: /(Android)\s([\d.]+)/,
1313
1313
  ios: /(Version)\/([\d.]+)/
1314
1314
  };
1315
- var H264_MIMETYPES = ["avc1.42E01E, mp4a.40.2", "avc1.58A01E, mp4a.40.2", "avc1.4D401E, mp4a.40.2", "avc1.64001E, mp4a.40.2", "avc1.42E01E", "mp4v.20.8", "mp4v.20.8, mp4a.40.2", "mp4v.20.240, mp4a.40.2"];
1315
+ var H264_MIMETYPES = ["avc1.42E01E, mp4a.40.2", "avc1.58A01E, mp4a.40.2", "avc1.4D401E, mp4a.40.2", "avc1.64001E, mp4a.40.2", "avc1.42E01E", "mp4v.20.8", "avc1.42E01E, mp4a.40.2", "avc1.58A01E, mp4a.40.2", "avc1.4D401E, mp4a.40.2", "avc1.64001E, mp4a.40.2", "mp4v.20.8, mp4a.40.2", "mp4v.20.240, mp4a.40.2"];
1316
1316
  var sniffer$1 = {
1317
1317
  get device() {
1318
1318
  var r2 = sniffer$1.os;
@@ -1457,7 +1457,7 @@ var sniffer$1 = {
1457
1457
  }
1458
1458
  }
1459
1459
  };
1460
- var version = "3.0.20-rc.3";
1460
+ var version = "3.0.19-rc.0";
1461
1461
  var ERROR_TYPE_MAP = {
1462
1462
  1: "media",
1463
1463
  2: "media",
@@ -3417,7 +3417,7 @@ var ResizeObserver = /* @__PURE__ */ function() {
3417
3417
  if (!this.observer) {
3418
3418
  return;
3419
3419
  }
3420
- this.observer.observe(target);
3420
+ this.observer && this.observer.observe(target);
3421
3421
  var _pid = target.getAttribute(PLATER_ID);
3422
3422
  var __handlers = this.__handlers;
3423
3423
  var index = -1;
@@ -3446,17 +3446,16 @@ var ResizeObserver = /* @__PURE__ */ function() {
3446
3446
  }
3447
3447
  });
3448
3448
  try {
3449
- var _this$observer;
3450
- (_this$observer = this.observer) === null || _this$observer === void 0 ? void 0 : _this$observer.unobserve(target);
3449
+ this.observer && this.observer.unobserve(target);
3451
3450
  } catch (e3) {
3452
3451
  }
3452
+ this.observer && this.observer.unobserve(target);
3453
3453
  i2 > -1 && this.__handlers.splice(i2, 1);
3454
3454
  }
3455
3455
  }, {
3456
3456
  key: "destroyObserver",
3457
3457
  value: function destroyObserver() {
3458
- var _this$observer2;
3459
- (_this$observer2 = this.observer) === null || _this$observer2 === void 0 ? void 0 : _this$observer2.disconnect();
3458
+ this.observer && this.observer.disconnect();
3460
3459
  this.observer = null;
3461
3460
  this.__handlers = null;
3462
3461
  }
@@ -3488,8 +3487,7 @@ function addObserver(target, handler) {
3488
3487
  return resizeObserver;
3489
3488
  }
3490
3489
  function unObserver(target, handler) {
3491
- var _resizeObserver;
3492
- (_resizeObserver = resizeObserver) === null || _resizeObserver === void 0 ? void 0 : _resizeObserver.unObserver(target, handler);
3490
+ resizeObserver.unObserver(target, handler);
3493
3491
  }
3494
3492
  var pluginsManager = {
3495
3493
  pluginGroup: {},
@@ -4487,7 +4485,10 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
4487
4485
  }
4488
4486
  var _this$config = _this.config, autoplay2 = _this$config.autoplay, defaultPlaybackRate = _this$config.defaultPlaybackRate;
4489
4487
  XG_DEBUG.logInfo("player", "canPlayFunc, startTime", _this.__startTime);
4490
- _this._seekToStartTime();
4488
+ if (_this.__startTime > 0 && _this.duration > 0) {
4489
+ _this.currentTime = _this.__startTime > _this.duration ? _this.duration : _this.__startTime;
4490
+ _this.__startTime = -1;
4491
+ }
4491
4492
  _this.playbackRate = defaultPlaybackRate;
4492
4493
  (autoplay2 || _this._useAutoplay) && _this.mediaPlay();
4493
4494
  _this.off(CANPLAY, _this.canPlayFunc);
@@ -5109,7 +5110,10 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5109
5110
  reject(e3);
5110
5111
  };
5111
5112
  var _canplay = function _canplay2() {
5112
- _this9._seekToStartTime();
5113
+ if (_this9.duration > 0 && _this9.__startTime > 0) {
5114
+ _this9.currentTime = _this9.__startTime;
5115
+ _this9.__startTime = -1;
5116
+ }
5113
5117
  if (isPaused) {
5114
5118
  _this9.pause();
5115
5119
  }
@@ -5730,17 +5734,11 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5730
5734
  }, {
5731
5735
  key: "onLoadeddata",
5732
5736
  value: function onLoadeddata() {
5733
- var _this22 = this;
5734
5737
  this.isError = false;
5735
5738
  this.isSeeking = false;
5736
- if (this.__startTime > 0) {
5737
- if (this.duration > 0) {
5738
- this._seekToStartTime();
5739
- } else {
5740
- this.once(DURATION_CHANGE, function() {
5741
- _this22._seekToStartTime();
5742
- });
5743
- }
5739
+ if (this.__startTime > 0 && this.duration > 0) {
5740
+ this.currentTime = this.__startTime;
5741
+ this.__startTime = -1;
5744
5742
  }
5745
5743
  }
5746
5744
  }, {
@@ -5809,27 +5807,27 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5809
5807
  }, {
5810
5808
  key: "onWaiting",
5811
5809
  value: function onWaiting() {
5812
- var _this23 = this;
5810
+ var _this22 = this;
5813
5811
  if (this.waitTimer) {
5814
5812
  util$1.clearTimeout(this, this.waitTimer);
5815
5813
  }
5816
5814
  this.updateAcc("waiting");
5817
5815
  this.waitTimer = util$1.setTimeout(this, function() {
5818
- _this23.addClass(STATE_CLASS.LOADING);
5819
- _this23.emit(LOADING);
5820
- util$1.clearTimeout(_this23, _this23.waitTimer);
5821
- _this23.waitTimer = null;
5816
+ _this22.addClass(STATE_CLASS.LOADING);
5817
+ _this22.emit(LOADING);
5818
+ util$1.clearTimeout(_this22, _this22.waitTimer);
5819
+ _this22.waitTimer = null;
5822
5820
  }, this.config.minWaitDelay);
5823
5821
  }
5824
5822
  }, {
5825
5823
  key: "onPlaying",
5826
5824
  value: function onPlaying() {
5827
- var _this24 = this;
5825
+ var _this23 = this;
5828
5826
  this.isError = false;
5829
5827
  var NO_START = STATE_CLASS.NO_START, PAUSED = STATE_CLASS.PAUSED, ENDED2 = STATE_CLASS.ENDED, ERROR2 = STATE_CLASS.ERROR, REPLAY2 = STATE_CLASS.REPLAY, LOADING2 = STATE_CLASS.LOADING;
5830
5828
  var clsList = [NO_START, PAUSED, ENDED2, ERROR2, REPLAY2, LOADING2];
5831
5829
  clsList.forEach(function(cls) {
5832
- _this24.removeClass(cls);
5830
+ _this23.removeClass(cls);
5833
5831
  });
5834
5832
  if (!this._accPlayed.t && !this.paused && !this.ended) {
5835
5833
  this._accPlayed.t = (/* @__PURE__ */ new Date()).getTime();
@@ -5990,14 +5988,14 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5990
5988
  }, {
5991
5989
  key: "setConfig",
5992
5990
  value: function setConfig(config) {
5993
- var _this25 = this;
5991
+ var _this24 = this;
5994
5992
  if (!config) {
5995
5993
  return;
5996
5994
  }
5997
5995
  Object.keys(config).map(function(key) {
5998
5996
  if (key !== "plugins") {
5999
- _this25.config[key] = config[key];
6000
- var plugin = _this25.plugins[key.toLowerCase()];
5997
+ _this24.config[key] = config[key];
5998
+ var plugin = _this24.plugins[key.toLowerCase()];
6001
5999
  if (plugin && util$1.typeOf(plugin.setConfig) === "Function") {
6002
6000
  plugin.setConfig(config[key]);
6003
6001
  }
@@ -6007,20 +6005,20 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6007
6005
  }, {
6008
6006
  key: "playNext",
6009
6007
  value: function playNext(config) {
6010
- var _this26 = this;
6008
+ var _this25 = this;
6011
6009
  this.resetState();
6012
6010
  this.setConfig(config);
6013
6011
  this._currentTime = 0;
6014
6012
  this._duration = 0;
6015
6013
  runHooks(this, "playnext", function() {
6016
- _this26.start();
6017
- _this26.emit(PLAYNEXT, config);
6014
+ _this25.start();
6015
+ _this25.emit(PLAYNEXT, config);
6018
6016
  });
6019
6017
  }
6020
6018
  }, {
6021
6019
  key: "resize",
6022
6020
  value: function resize() {
6023
- var _this27 = this;
6021
+ var _this26 = this;
6024
6022
  if (!this.media) {
6025
6023
  return;
6026
6024
  }
@@ -6060,7 +6058,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6060
6058
  }
6061
6059
  if (!this.fullscreen && !this.cssfullscreen) {
6062
6060
  Object.keys(_style).forEach(function(key) {
6063
- _this27.root.style[key] = _style[key];
6061
+ _this26.root.style[key] = _style[key];
6064
6062
  });
6065
6063
  }
6066
6064
  if (videoFillMode === "fillHeight" && fit < videoFit || videoFillMode === "fillWidth" && fit > videoFit) {
@@ -6102,14 +6100,6 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6102
6100
  url
6103
6101
  };
6104
6102
  }
6105
- }, {
6106
- key: "_seekToStartTime",
6107
- value: function _seekToStartTime() {
6108
- if (this.__startTime > 0 && this.duration > 0) {
6109
- this.currentTime = this.__startTime > this.duration ? this.duration : this.__startTime;
6110
- this.__startTime = -1;
6111
- }
6112
- }
6113
6103
  }, {
6114
6104
  key: "state",
6115
6105
  get: function get() {
@@ -6160,15 +6150,15 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6160
6150
  return this.config.definition.list || [];
6161
6151
  },
6162
6152
  set: function set(list) {
6163
- var _this28 = this;
6153
+ var _this27 = this;
6164
6154
  var definition = this.config.definition;
6165
6155
  var curDef = null;
6166
6156
  var targetDef = null;
6167
6157
  definition.list = list;
6168
6158
  this.emit("resourceReady", list);
6169
6159
  list.forEach(function(item) {
6170
- var _this28$curDefinition;
6171
- if (((_this28$curDefinition = _this28.curDefinition) === null || _this28$curDefinition === void 0 ? void 0 : _this28$curDefinition.definition) === item.definition) {
6160
+ var _this27$curDefinition;
6161
+ if (((_this27$curDefinition = _this27.curDefinition) === null || _this27$curDefinition === void 0 ? void 0 : _this27$curDefinition.definition) === item.definition) {
6172
6162
  curDef = item;
6173
6163
  }
6174
6164
  if (definition.defaultDefinition === item.definition) {
@@ -8453,7 +8443,7 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
8453
8443
  }
8454
8444
  this.on(DURATION_CHANGE, function() {
8455
8445
  var player2 = _this2.player, config2 = _this2.config;
8456
- if (player2.duration > 0 && player2.duration * 1e3 < config2.moveDuration) {
8446
+ if (player2.duration * 1e3 < config2.moveDuration) {
8457
8447
  config2.moveDuration = player2.duration * 1e3;
8458
8448
  }
8459
8449
  });
@@ -8767,13 +8757,10 @@ var MobilePlugin = /* @__PURE__ */ function(_Plugin) {
8767
8757
  }, {
8768
8758
  key: "updateBrightness",
8769
8759
  value: function updateBrightness(percent) {
8770
- var pos = this.pos, config = this.config, xgMask = this.xgMask;
8771
- if (!config.darkness) {
8772
- return;
8773
- }
8774
8760
  if (this.player.rotateDeg) {
8775
8761
  percent = -percent;
8776
8762
  }
8763
+ var pos = this.pos, config = this.config, xgMask = this.xgMask;
8777
8764
  var light = pos.light + 0.8 * percent;
8778
8765
  light = light > config.maxDarkness ? config.maxDarkness : light < 0 ? 0 : light;
8779
8766
  if (xgMask) {
@@ -13755,7 +13742,7 @@ class VePlayerBase {
13755
13742
  * @returns
13756
13743
  */
13757
13744
  get playerVersion() {
13758
- return "2.4.1-rc.1";
13745
+ return "2.4.2-rc.0";
13759
13746
  }
13760
13747
  /** {zh}
13761
13748
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -19076,29 +19063,6 @@ async function isRTMSupportCodec(codec = RTMCodec.H264) {
19076
19063
  return RtmPlugin.isSupportedH264();
19077
19064
  return false;
19078
19065
  }
19079
- const getAbrStrategy = async (options) => {
19080
- var _a, _b;
19081
- const streamType = options.url && getStreamType(options.url);
19082
- if (streamType === "rtm") {
19083
- return {};
19084
- }
19085
- 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;
19086
- if (!abrOptions) {
19087
- return {};
19088
- }
19089
- const abrPlugin = await load(DynamicModule.PluginAbr).catch(() => void 0);
19090
- return {
19091
- options: {
19092
- [streamType === "flv" ? "abr" : "hlsabr"]: {
19093
- ...abrOptions,
19094
- open: abrOptions.enable ?? true
19095
- }
19096
- },
19097
- plugins: [
19098
- streamType === "flv" ? abrPlugin == null ? void 0 : abrPlugin.AbrPlugin : abrPlugin == null ? void 0 : abrPlugin.HlsAbrPlugin
19099
- ]
19100
- };
19101
- };
19102
19066
  const rtmStrategy = {
19103
19067
  options: {},
19104
19068
  module: DynamicModule.PluginRtm
@@ -19113,8 +19077,6 @@ const generateFallbackUrl = (url) => {
19113
19077
  const getRtmStrategy = async (options, player) => {
19114
19078
  var _a;
19115
19079
  let backupStrategy;
19116
- let backupOptions = {};
19117
- let backupModule = [];
19118
19080
  const { url } = options;
19119
19081
  const {
19120
19082
  fallbackUrl,
@@ -19129,7 +19091,7 @@ const getRtmStrategy = async (options, player) => {
19129
19091
  } else if (backupType === "hls" && (sniffer$1.device !== "mobile" || ((_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.enableMSE)) && util.isMseSupported(Codec.H264)) {
19130
19092
  backupStrategy = createHlsMseStrategy(options);
19131
19093
  }
19132
- const [rtmCdn, backupCdn, backupAbr] = await Promise.all([
19094
+ const [rtmCdn, backupCdn] = await Promise.all([
19133
19095
  load(rtmStrategy.module).then((module) => {
19134
19096
  return module.RtmPlugin;
19135
19097
  }).catch(() => void 0),
@@ -19139,18 +19101,8 @@ const getRtmStrategy = async (options, player) => {
19139
19101
  } else if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule.PluginHls) {
19140
19102
  return module.HlsPlugin;
19141
19103
  }
19142
- }).catch(() => void 0),
19143
- getAbrStrategy({ ...options, url: actualFallbackUrl }).catch(
19144
- () => void 0
19145
- )
19104
+ }).catch(() => void 0)
19146
19105
  ]);
19147
- if (backupType) {
19148
- backupOptions = {
19149
- ...backupStrategy == null ? void 0 : backupStrategy.options,
19150
- ...backupAbr == null ? void 0 : backupAbr.options
19151
- };
19152
- backupModule = [backupCdn, ...(backupAbr == null ? void 0 : backupAbr.plugins) ?? []];
19153
- }
19154
19106
  const [RTMSupported, RTMSupportCodec] = await Promise.all([
19155
19107
  isRTMSupported(),
19156
19108
  isRTMSupportCodec()
@@ -19168,7 +19120,7 @@ const getRtmStrategy = async (options, player) => {
19168
19120
  }
19169
19121
  return {
19170
19122
  options: {
19171
- ...backupOptions || {},
19123
+ ...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
19172
19124
  url: actualFallbackUrl,
19173
19125
  _RTMdegrade: {
19174
19126
  _originRtmUrl: url,
@@ -19176,19 +19128,19 @@ const getRtmStrategy = async (options, player) => {
19176
19128
  _isRTMSupportCodec: RTMSupportCodec
19177
19129
  }
19178
19130
  },
19179
- plugins: backupModule
19131
+ plugins: backupCdn ? [backupCdn] : []
19180
19132
  };
19181
19133
  }
19182
19134
  return {
19183
19135
  options: {
19184
- ...backupOptions || {},
19136
+ ...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
19185
19137
  url: enableRTMAutoTranscode ? util.appendSearchParams(url, { enableRTMAutoTranscode: "true" }) : void 0,
19186
19138
  _RTMdegrade: void 0,
19187
19139
  rts: {
19188
19140
  retryCount: 0,
19189
19141
  ...ret,
19190
19142
  backupURL: actualFallbackUrl,
19191
- backupConstruct: backupModule
19143
+ backupConstruct: backupCdn
19192
19144
  }
19193
19145
  },
19194
19146
  plugins: rtmCdn ? [rtmCdn] : []
@@ -22042,10 +21994,10 @@ class Logger extends Plugin {
22042
21994
  user_id: this._userId,
22043
21995
  device_id: this._deviceId,
22044
21996
  ext: {
22045
- veplayer_version: "2.4.1-rc.1",
22046
- flv_version: "3.0.20-rc.3",
22047
- hls_version: "3.0.20-rc.3",
22048
- rts_version: "0.2.1-alpha.1"
21997
+ veplayer_version: "2.4.2-rc.0",
21998
+ flv_version: "3.0.19-rc.0",
21999
+ hls_version: "3.0.19-rc.0",
22000
+ rts_version: "0.2.1-alpha.2"
22049
22001
  }
22050
22002
  });
22051
22003
  }
@@ -22339,6 +22291,29 @@ const getDrmStrategy = async (options, player) => {
22339
22291
  }
22340
22292
  return {};
22341
22293
  };
22294
+ const getAbrStrategy = async (options) => {
22295
+ var _a, _b;
22296
+ const streamType = options.url && getStreamType(options.url);
22297
+ if (streamType === "rtm") {
22298
+ return {};
22299
+ }
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;
22301
+ if (!abrOptions) {
22302
+ return {};
22303
+ }
22304
+ const abrPlugin = await load(DynamicModule.PluginAbr).catch(() => void 0);
22305
+ return {
22306
+ options: {
22307
+ [streamType === "flv" ? "abr" : "hlsabr"]: {
22308
+ ...abrOptions,
22309
+ open: abrOptions.enable ?? true
22310
+ }
22311
+ },
22312
+ plugins: [
22313
+ streamType === "flv" ? abrPlugin == null ? void 0 : abrPlugin.AbrPlugin : abrPlugin == null ? void 0 : abrPlugin.HlsAbrPlugin
22314
+ ]
22315
+ };
22316
+ };
22342
22317
  VeI18n.extend([
22343
22318
  {
22344
22319
  LANG: "zh-cn",
@@ -22510,28 +22485,6 @@ class VePlayerLive extends VePlayerBase {
22510
22485
  var _a, _b, _c;
22511
22486
  return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.flv) == null ? void 0 : _c.getStats();
22512
22487
  }
22513
- /** {zh}
22514
- * @brief 调用此方法开始播放 。
22515
- */
22516
- /** {en}
22517
- * @brief Starts playback.
22518
- */
22519
- play() {
22520
- this.openAbr();
22521
- /* istanbul ignore next -- @preserve */
22522
- return this._player.play();
22523
- }
22524
- /** {zh}
22525
- * @brief 调用此方法暂停播放。
22526
- */
22527
- /** {en}
22528
- * @brief Pauses playback.
22529
- */
22530
- pause() {
22531
- this.closeAbr();
22532
- /* istanbul ignore next -- @preserve */
22533
- return this._player.pause();
22534
- }
22535
22488
  }
22536
22489
  async function createLivePlayer(options) {
22537
22490
  var _a, _b;