@volcengine/veplayer 2.6.0-rc.5 → 2.6.1-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.
@@ -1457,7 +1457,7 @@ var sniffer$1 = {
1457
1457
  }
1458
1458
  }
1459
1459
  };
1460
- var version = "3.0.21-rc.5";
1460
+ var version = "3.0.21-alpha.13";
1461
1461
  var ERROR_TYPE_MAP = {
1462
1462
  1: "media",
1463
1463
  2: "media",
@@ -1759,7 +1759,7 @@ var MediaProxy = /* @__PURE__ */ function(_EventEmitter) {
1759
1759
  if (options.autoplayMuted && !Object.prototype.hasOwnProperty.call(_this.mediaConfig, "muted")) {
1760
1760
  _this.mediaConfig.muted = true;
1761
1761
  }
1762
- _this.media = util$1.createDom(_this.mediaConfig.mediaType, "", _this.mediaConfig, "");
1762
+ _this.media = options.mediaEl instanceof HTMLMediaElement ? options.mediaEl : typeof options.mediaEl === "function" ? options.mediaEl(_this.mediaConfig) : util$1.createDom(_this.mediaConfig.mediaType, "", _this.mediaConfig, "");
1763
1763
  if (options.defaultPlaybackRate) {
1764
1764
  _this.media.defaultPlaybackRate = _this.media.playbackRate = options.defaultPlaybackRate;
1765
1765
  }
@@ -1773,6 +1773,9 @@ var MediaProxy = /* @__PURE__ */ function(_EventEmitter) {
1773
1773
  if (options.autoplay) {
1774
1774
  _this.media.autoplay = true;
1775
1775
  }
1776
+ if (options.playsinline) {
1777
+ _this.media.playsinline = true;
1778
+ }
1776
1779
  _this._interval = {};
1777
1780
  _this.mediaEventMiddleware = {};
1778
1781
  _this.attachVideoEvents();
@@ -2493,8 +2496,9 @@ function removeHooks(hookName, handler) {
2493
2496
  if (index !== -1) {
2494
2497
  hooks.splice(index, 1);
2495
2498
  }
2499
+ } else if (__hooks[hookName]) {
2500
+ __hooks[hookName] = null;
2496
2501
  }
2497
- delete __hooks[hookName];
2498
2502
  }
2499
2503
  function usePluginHooks(pluginName) {
2500
2504
  if (!this.plugins || !this.plugins[pluginName.toLowerCase()]) {
@@ -4750,18 +4754,10 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
4750
4754
  ret.destroy();
4751
4755
  }
4752
4756
  this.root.setAttribute(PLATER_ID, this.playerId);
4757
+ this.media.setAttribute(PLATER_ID, this.playerId);
4753
4758
  (_instManager = instManager) === null || _instManager === void 0 ? void 0 : _instManager.add(this);
4754
4759
  pluginsManager.init(this);
4755
4760
  this._initBaseDoms();
4756
- var XgVideoProxy = this.constructor.XgVideoProxy;
4757
- if (XgVideoProxy && this.mediaConfig.mediaType === XgVideoProxy.mediaType) {
4758
- var _el = this.innerContainer || this.root;
4759
- this.detachVideoEvents(this.media);
4760
- var _nVideo = new XgVideoProxy(_el, this.config, this.mediaConfig);
4761
- this.attachVideoEvents(_nVideo);
4762
- this.media = _nVideo;
4763
- }
4764
- this.media.setAttribute(PLATER_ID, this.playerId);
4765
4761
  if (this.config.controls) {
4766
4762
  var _root = this.config.controls.root || null;
4767
4763
  var controls = pluginsManager.register(this, Controls, {
@@ -5427,6 +5423,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5427
5423
  this.hasStart = false;
5428
5424
  this._useAutoplay = false;
5429
5425
  root2.removeAttribute(PLATER_ID);
5426
+ media.removeAttribute(PLATER_ID);
5430
5427
  this.updateAcc("destroy");
5431
5428
  this._unbindEvents();
5432
5429
  this._detachSourceEvents(this.media);
@@ -5445,7 +5442,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5445
5442
  innerContainer.removeChild(_c[i2]);
5446
5443
  }
5447
5444
  }
5448
- !innerContainer && media instanceof window.Node && root2.contains(media) && root2.removeChild(media);
5445
+ !innerContainer && media instanceof window.Node && root2.contains(media) && !this.config.remainMediaAfterDestroy && root2.removeChild(media);
5449
5446
  ["topBar", "leftBar", "rightBar", "innerContainer"].map(function(item) {
5450
5447
  _this18[item] && root2.removeChild(_this18[item]);
5451
5448
  _this18[item] = null;
@@ -5971,6 +5968,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5971
5968
  }, {
5972
5969
  key: "resizePosition",
5973
5970
  value: function resizePosition() {
5971
+ var _this25 = this;
5974
5972
  var _this$videoPos = this.videoPos, vy = _this$videoPos.vy, vx = _this$videoPos.vx, h2 = _this$videoPos.h, w2 = _this$videoPos.w;
5975
5973
  var rotate = this.videoPos.rotate;
5976
5974
  if (rotate < 0 && h2 < 0 && w2 < 0) {
@@ -5995,6 +5993,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5995
5993
  var root2 = this.root, innerContainer = this.innerContainer;
5996
5994
  var width = root2.offsetWidth;
5997
5995
  var height = innerContainer ? innerContainer.offsetHeight : root2.offsetHeight;
5996
+ var styles = {};
5998
5997
  var rHeight = height;
5999
5998
  var rWidth = width;
6000
5999
  if (_t % 2 === 0) {
@@ -6004,8 +6003,10 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6004
6003
  _pos.y = _t === 2 ? 0 - offsetY : offsetY;
6005
6004
  offsetX = vx > 0 ? (100 - w2) / 2 - vx : 0;
6006
6005
  _pos.x = _t === 2 ? 0 - offsetX : offsetX;
6007
- this.media.style.width = "".concat(rWidth, "px");
6008
- this.media.style.height = "".concat(rHeight, "px");
6006
+ styles.width = "".concat(rWidth, "px");
6007
+ styles.height = "".concat(rHeight, "px");
6008
+ styles.maxWidth = "";
6009
+ styles.maxHeight = "";
6009
6010
  } else if (_t % 2 === 1) {
6010
6011
  rWidth = height;
6011
6012
  rHeight = width;
@@ -6015,12 +6016,17 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6015
6016
  offsetY = offset / 2 / rHeight * 100;
6016
6017
  _pos.y = _t === 3 ? offsetY + vx / 2 : offsetY - vx / 2;
6017
6018
  _pos.scale = scale;
6018
- this.media.style.width = "".concat(rWidth, "px");
6019
- this.media.style.height = "".concat(rHeight, "px");
6019
+ styles.width = "".concat(rWidth, "px");
6020
+ styles.maxWidth = "".concat(rWidth, "px");
6021
+ styles.height = "".concat(rHeight, "px");
6022
+ styles.maxHeight = "".concat(rHeight, "px");
6020
6023
  }
6021
6024
  var formStyle = util$1.getTransformStyle(_pos, this.media.style.transform || this.media.style.webkitTransform);
6022
- this.media.style.transform = formStyle;
6023
- this.media.style.webkitTransform = formStyle;
6025
+ styles.transform = formStyle;
6026
+ styles.webkitTransform = formStyle;
6027
+ Object.keys(styles).map(function(key) {
6028
+ _this25.media.style[key] = styles[key];
6029
+ });
6024
6030
  }
6025
6031
  }, {
6026
6032
  key: "position",
@@ -6044,14 +6050,14 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6044
6050
  }, {
6045
6051
  key: "setConfig",
6046
6052
  value: function setConfig(config) {
6047
- var _this25 = this;
6053
+ var _this26 = this;
6048
6054
  if (!config) {
6049
6055
  return;
6050
6056
  }
6051
6057
  Object.keys(config).map(function(key) {
6052
6058
  if (key !== "plugins") {
6053
- _this25.config[key] = config[key];
6054
- var plugin = _this25.plugins[key.toLowerCase()];
6059
+ _this26.config[key] = config[key];
6060
+ var plugin = _this26.plugins[key.toLowerCase()];
6055
6061
  if (plugin && util$1.typeOf(plugin.setConfig) === "Function") {
6056
6062
  plugin.setConfig(config[key]);
6057
6063
  }
@@ -6061,20 +6067,20 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6061
6067
  }, {
6062
6068
  key: "playNext",
6063
6069
  value: function playNext(config) {
6064
- var _this26 = this;
6070
+ var _this27 = this;
6065
6071
  this.resetState();
6066
6072
  this.setConfig(config);
6067
6073
  this._currentTime = 0;
6068
6074
  this._duration = 0;
6069
6075
  runHooks(this, "playnext", function() {
6070
- _this26.start();
6071
- _this26.emit(PLAYNEXT, config);
6076
+ _this27.start();
6077
+ _this27.emit(PLAYNEXT, config);
6072
6078
  });
6073
6079
  }
6074
6080
  }, {
6075
6081
  key: "resize",
6076
6082
  value: function resize() {
6077
- var _this27 = this;
6083
+ var _this28 = this;
6078
6084
  if (!this.media) {
6079
6085
  return;
6080
6086
  }
@@ -6114,7 +6120,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6114
6120
  }
6115
6121
  if (!this.fullscreen && !this.cssfullscreen) {
6116
6122
  Object.keys(_style).forEach(function(key) {
6117
- _this27.root.style[key] = _style[key];
6123
+ _this28.root.style[key] = _style[key];
6118
6124
  });
6119
6125
  }
6120
6126
  if (videoFillMode === "fillHeight" && fit < videoFit || videoFillMode === "fillWidth" && fit > videoFit) {
@@ -6214,15 +6220,15 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6214
6220
  return this.config.definition.list || [];
6215
6221
  },
6216
6222
  set: function set(list) {
6217
- var _this28 = this;
6223
+ var _this29 = this;
6218
6224
  var definition = this.config.definition;
6219
6225
  var curDef = null;
6220
6226
  var targetDef = null;
6221
6227
  definition.list = list;
6222
6228
  this.emit("resourceReady", list);
6223
6229
  list.forEach(function(item) {
6224
- var _this28$curDefinition;
6225
- if (((_this28$curDefinition = _this28.curDefinition) === null || _this28$curDefinition === void 0 ? void 0 : _this28$curDefinition.definition) === item.definition) {
6230
+ var _this29$curDefinition;
6231
+ if (((_this29$curDefinition = _this29.curDefinition) === null || _this29$curDefinition === void 0 ? void 0 : _this29$curDefinition.definition) === item.definition) {
6226
6232
  curDef = item;
6227
6233
  }
6228
6234
  if (definition.defaultDefinition === item.definition) {
@@ -13386,6 +13392,40 @@ const getUrlObject = (url) => {
13386
13392
  return;
13387
13393
  }
13388
13394
  };
13395
+ function getAttributes(dom) {
13396
+ const attributes = {};
13397
+ for (const attr of dom.attributes) {
13398
+ attributes[attr.name] = attr.value;
13399
+ }
13400
+ return attributes;
13401
+ }
13402
+ function setAttributes(dom, attrs = {}) {
13403
+ Object.keys(attrs).forEach((item) => {
13404
+ const key = item;
13405
+ const value = attrs[item];
13406
+ if (value) {
13407
+ dom == null ? void 0 : dom.setAttribute(key, value);
13408
+ }
13409
+ });
13410
+ return dom;
13411
+ }
13412
+ function replaceAttributes(dom, attrs = {}) {
13413
+ const attributes = getAttributes(dom);
13414
+ Object.keys(attributes).forEach((attr) => {
13415
+ if (attrs[attr]) {
13416
+ dom == null ? void 0 : dom.setAttribute(attr, attrs[attr]);
13417
+ } else {
13418
+ dom == null ? void 0 : dom.removeAttribute(attr);
13419
+ }
13420
+ });
13421
+ return dom;
13422
+ }
13423
+ var DomUtils = /* @__PURE__ */ Object.freeze({
13424
+ __proto__: null,
13425
+ getAttributes,
13426
+ replaceAttributes,
13427
+ setAttributes
13428
+ });
13389
13429
  const H264_MIME = 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';
13390
13430
  const H265_MIME = [
13391
13431
  'video/mp4;codecs="hev1.1.6.L120.90"',
@@ -13448,6 +13488,7 @@ function isMMSSupported$2(codec = Codec.H264) {
13448
13488
  }
13449
13489
  const util = {
13450
13490
  ...util$1,
13491
+ ...DomUtils,
13451
13492
  getStreamType,
13452
13493
  isMseSupported: isMseSupported$2,
13453
13494
  isSoftDecodeSupported: isSoftDecodeSupported$1,
@@ -14110,6 +14151,25 @@ class VeI18n {
14110
14151
  }
14111
14152
  }
14112
14153
  var veplayerBase = "";
14154
+ class CustomMedia {
14155
+ constructor(el) {
14156
+ __publicField(this, "_videoAttributes");
14157
+ __publicField(this, "_el");
14158
+ this._videoAttributes = getAttributes(el);
14159
+ this._el = el;
14160
+ }
14161
+ get options() {
14162
+ return {
14163
+ remainMediaAfterDestroy: true,
14164
+ mediaEl: (mediaConfig) => {
14165
+ return setAttributes(this._el, mediaConfig);
14166
+ }
14167
+ };
14168
+ }
14169
+ destroy() {
14170
+ replaceAttributes(this._el, this._videoAttributes);
14171
+ }
14172
+ }
14113
14173
  const { POSITIONS: XGPosition } = Plugin;
14114
14174
  const POSITIONS$1 = {
14115
14175
  ...XGPosition,
@@ -14165,20 +14225,25 @@ class VePlayerBase {
14165
14225
  __publicField(this, "_previousPrepareResult");
14166
14226
  __publicField(this, "_i18nManager");
14167
14227
  __publicField(this, "_events", {});
14228
+ __publicField(this, "_customMedia");
14168
14229
  __publicField(this, "_errorCallback");
14169
- var _a, _b, _c, _d, _e;
14230
+ var _a, _b, _c, _d, _e, _f;
14170
14231
  this._sourceManager = options.sourceManager;
14171
14232
  this._preparePlugins = options.preparePlugins;
14172
14233
  this._previousPrepareResult = options.prepareResult;
14173
14234
  this._i18nManager = options.i18nManager ?? new VeI18n({
14174
14235
  i18n: options.i18n
14175
14236
  });
14237
+ if (options.mediaElement) {
14238
+ this._customMedia = new CustomMedia(options.mediaElement);
14239
+ }
14176
14240
  const xgOptions = transformOption({
14177
14241
  ...options,
14178
- ...(_a = this._previousPrepareResult) == null ? void 0 : _a.options
14242
+ ...(_a = this._customMedia) == null ? void 0 : _a.options,
14243
+ ...(_b = this._previousPrepareResult) == null ? void 0 : _b.options
14179
14244
  });
14180
14245
  const plugins = [
14181
- ...((_b = this._previousPrepareResult) == null ? void 0 : _b.plugins) ?? [],
14246
+ ...((_c = this._previousPrepareResult) == null ? void 0 : _c.plugins) ?? [],
14182
14247
  ...options.plugins ?? DEFAULT_PLUGINS
14183
14248
  ];
14184
14249
  const topRightPlugins = [];
@@ -14190,11 +14255,11 @@ class VePlayerBase {
14190
14255
  ...DEFAULT_OPTIONS,
14191
14256
  ...xgOptions,
14192
14257
  definition: {
14193
- list: ((_c = this._sourceManager.source) == null ? void 0 : _c.definitions) ?? [],
14194
- defaultDefinition: (_d = this._sourceManager.definition) == null ? void 0 : _d.definition,
14258
+ list: ((_d = this._sourceManager.source) == null ? void 0 : _d.definitions) ?? [],
14259
+ defaultDefinition: (_e = this._sourceManager.definition) == null ? void 0 : _e.definition,
14195
14260
  ...options.definition ?? {}
14196
14261
  },
14197
- url: (_e = this._sourceManager.definition) == null ? void 0 : _e.url,
14262
+ url: (_f = this._sourceManager.definition) == null ? void 0 : _f.url,
14198
14263
  sources: {
14199
14264
  ...options.sources ?? {},
14200
14265
  sourceManager: this._sourceManager
@@ -14374,7 +14439,7 @@ class VePlayerBase {
14374
14439
  * @brief Retrieve the player SDK version number.
14375
14440
  */
14376
14441
  get playerVersion() {
14377
- return "2.6.0-rc.5";
14442
+ return "2.6.1-rc.0";
14378
14443
  }
14379
14444
  /** {zh}
14380
14445
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -14848,8 +14913,10 @@ class VePlayerBase {
14848
14913
  * @brief Destroys the player instance.
14849
14914
  */
14850
14915
  destroy() {
14916
+ var _a;
14851
14917
  this._player.off(ERROR, this._errorCallback);
14852
14918
  this._player.destroy();
14919
+ (_a = this._customMedia) == null ? void 0 : _a.destroy();
14853
14920
  }
14854
14921
  /** {zh}
14855
14922
  * @hidden
@@ -22739,9 +22806,9 @@ class Logger extends Plugin {
22739
22806
  device_id: this._deviceId,
22740
22807
  error_report_stop: true,
22741
22808
  ext: {
22742
- veplayer_version: "2.6.0-rc.5",
22809
+ veplayer_version: "2.6.1-rc.0",
22743
22810
  flv_version: "3.0.21-rc.5",
22744
- hls_version: "3.0.21-rc.5",
22811
+ hls_version: "3.0.21-rc.20",
22745
22812
  rts_version: "0.2.1-alpha.14"
22746
22813
  }
22747
22814
  });