@byteplus/veplayer 2.4.0 → 2.4.1-rc.1

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