@volcengine/veplayer 2.6.0 → 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.
@@ -1395,6 +1395,7 @@ interface VePlayerBaseOptions extends Omit<PlayerOptions, "autoplay" | "i18n"> {
1395
1395
  * @default false
1396
1396
  */
1397
1397
  closeVideoDblclick?: boolean;
1398
+ mediaElement?: HTMLVideoElement | null;
1398
1399
  }
1399
1400
  /** {zh}
1400
1401
  * @list option
@@ -1595,6 +1596,7 @@ declare class VePlayerBase {
1595
1596
  private _previousPrepareResult?;
1596
1597
  private _i18nManager;
1597
1598
  private _events;
1599
+ private _customMedia?;
1598
1600
  private _errorCallback;
1599
1601
  /** {zh}
1600
1602
  * @hidden
@@ -3729,6 +3731,7 @@ declare namespace strategy {
3729
3731
  * @default false
3730
3732
  */
3731
3733
  closeVideoDblclick?: boolean;
3734
+ mediaElement?: HTMLVideoElement | null;
3732
3735
  }
3733
3736
  /** {zh}
3734
3737
  * @list option
@@ -1452,7 +1452,7 @@ var sniffer = {
1452
1452
  }
1453
1453
  }
1454
1454
  };
1455
- var version = "3.0.21-rc.5";
1455
+ var version = "3.0.21-alpha.13";
1456
1456
  var ERROR_TYPE_MAP = {
1457
1457
  1: "media",
1458
1458
  2: "media",
@@ -1754,7 +1754,7 @@ var MediaProxy = /* @__PURE__ */ function(_EventEmitter) {
1754
1754
  if (options.autoplayMuted && !Object.prototype.hasOwnProperty.call(_this.mediaConfig, "muted")) {
1755
1755
  _this.mediaConfig.muted = true;
1756
1756
  }
1757
- _this.media = util.createDom(_this.mediaConfig.mediaType, "", _this.mediaConfig, "");
1757
+ _this.media = options.mediaEl instanceof HTMLMediaElement ? options.mediaEl : typeof options.mediaEl === "function" ? options.mediaEl(_this.mediaConfig) : util.createDom(_this.mediaConfig.mediaType, "", _this.mediaConfig, "");
1758
1758
  if (options.defaultPlaybackRate) {
1759
1759
  _this.media.defaultPlaybackRate = _this.media.playbackRate = options.defaultPlaybackRate;
1760
1760
  }
@@ -1768,6 +1768,9 @@ var MediaProxy = /* @__PURE__ */ function(_EventEmitter) {
1768
1768
  if (options.autoplay) {
1769
1769
  _this.media.autoplay = true;
1770
1770
  }
1771
+ if (options.playsinline) {
1772
+ _this.media.playsinline = true;
1773
+ }
1771
1774
  _this._interval = {};
1772
1775
  _this.mediaEventMiddleware = {};
1773
1776
  _this.attachVideoEvents();
@@ -2488,8 +2491,9 @@ function removeHooks(hookName, handler) {
2488
2491
  if (index !== -1) {
2489
2492
  hooks.splice(index, 1);
2490
2493
  }
2494
+ } else if (__hooks[hookName]) {
2495
+ __hooks[hookName] = null;
2491
2496
  }
2492
- delete __hooks[hookName];
2493
2497
  }
2494
2498
  function usePluginHooks(pluginName) {
2495
2499
  if (!this.plugins || !this.plugins[pluginName.toLowerCase()]) {
@@ -4745,18 +4749,10 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
4745
4749
  ret.destroy();
4746
4750
  }
4747
4751
  this.root.setAttribute(PLATER_ID, this.playerId);
4752
+ this.media.setAttribute(PLATER_ID, this.playerId);
4748
4753
  (_instManager = instManager) === null || _instManager === void 0 ? void 0 : _instManager.add(this);
4749
4754
  pluginsManager.init(this);
4750
4755
  this._initBaseDoms();
4751
- var XgVideoProxy = this.constructor.XgVideoProxy;
4752
- if (XgVideoProxy && this.mediaConfig.mediaType === XgVideoProxy.mediaType) {
4753
- var _el = this.innerContainer || this.root;
4754
- this.detachVideoEvents(this.media);
4755
- var _nVideo = new XgVideoProxy(_el, this.config, this.mediaConfig);
4756
- this.attachVideoEvents(_nVideo);
4757
- this.media = _nVideo;
4758
- }
4759
- this.media.setAttribute(PLATER_ID, this.playerId);
4760
4756
  if (this.config.controls) {
4761
4757
  var _root = this.config.controls.root || null;
4762
4758
  var controls = pluginsManager.register(this, Controls, {
@@ -5422,6 +5418,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5422
5418
  this.hasStart = false;
5423
5419
  this._useAutoplay = false;
5424
5420
  root2.removeAttribute(PLATER_ID);
5421
+ media.removeAttribute(PLATER_ID);
5425
5422
  this.updateAcc("destroy");
5426
5423
  this._unbindEvents();
5427
5424
  this._detachSourceEvents(this.media);
@@ -5440,7 +5437,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5440
5437
  innerContainer.removeChild(_c[i]);
5441
5438
  }
5442
5439
  }
5443
- !innerContainer && media instanceof window.Node && root2.contains(media) && root2.removeChild(media);
5440
+ !innerContainer && media instanceof window.Node && root2.contains(media) && !this.config.remainMediaAfterDestroy && root2.removeChild(media);
5444
5441
  ["topBar", "leftBar", "rightBar", "innerContainer"].map(function(item) {
5445
5442
  _this18[item] && root2.removeChild(_this18[item]);
5446
5443
  _this18[item] = null;
@@ -5966,6 +5963,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5966
5963
  }, {
5967
5964
  key: "resizePosition",
5968
5965
  value: function resizePosition() {
5966
+ var _this25 = this;
5969
5967
  var _this$videoPos = this.videoPos, vy = _this$videoPos.vy, vx = _this$videoPos.vx, h = _this$videoPos.h, w = _this$videoPos.w;
5970
5968
  var rotate = this.videoPos.rotate;
5971
5969
  if (rotate < 0 && h < 0 && w < 0) {
@@ -5990,6 +5988,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5990
5988
  var root2 = this.root, innerContainer = this.innerContainer;
5991
5989
  var width = root2.offsetWidth;
5992
5990
  var height = innerContainer ? innerContainer.offsetHeight : root2.offsetHeight;
5991
+ var styles = {};
5993
5992
  var rHeight = height;
5994
5993
  var rWidth = width;
5995
5994
  if (_t % 2 === 0) {
@@ -5999,8 +5998,10 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
5999
5998
  _pos.y = _t === 2 ? 0 - offsetY : offsetY;
6000
5999
  offsetX = vx > 0 ? (100 - w) / 2 - vx : 0;
6001
6000
  _pos.x = _t === 2 ? 0 - offsetX : offsetX;
6002
- this.media.style.width = "".concat(rWidth, "px");
6003
- this.media.style.height = "".concat(rHeight, "px");
6001
+ styles.width = "".concat(rWidth, "px");
6002
+ styles.height = "".concat(rHeight, "px");
6003
+ styles.maxWidth = "";
6004
+ styles.maxHeight = "";
6004
6005
  } else if (_t % 2 === 1) {
6005
6006
  rWidth = height;
6006
6007
  rHeight = width;
@@ -6010,12 +6011,17 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6010
6011
  offsetY = offset / 2 / rHeight * 100;
6011
6012
  _pos.y = _t === 3 ? offsetY + vx / 2 : offsetY - vx / 2;
6012
6013
  _pos.scale = scale;
6013
- this.media.style.width = "".concat(rWidth, "px");
6014
- this.media.style.height = "".concat(rHeight, "px");
6014
+ styles.width = "".concat(rWidth, "px");
6015
+ styles.maxWidth = "".concat(rWidth, "px");
6016
+ styles.height = "".concat(rHeight, "px");
6017
+ styles.maxHeight = "".concat(rHeight, "px");
6015
6018
  }
6016
6019
  var formStyle = util.getTransformStyle(_pos, this.media.style.transform || this.media.style.webkitTransform);
6017
- this.media.style.transform = formStyle;
6018
- this.media.style.webkitTransform = formStyle;
6020
+ styles.transform = formStyle;
6021
+ styles.webkitTransform = formStyle;
6022
+ Object.keys(styles).map(function(key) {
6023
+ _this25.media.style[key] = styles[key];
6024
+ });
6019
6025
  }
6020
6026
  }, {
6021
6027
  key: "position",
@@ -6039,14 +6045,14 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6039
6045
  }, {
6040
6046
  key: "setConfig",
6041
6047
  value: function setConfig(config) {
6042
- var _this25 = this;
6048
+ var _this26 = this;
6043
6049
  if (!config) {
6044
6050
  return;
6045
6051
  }
6046
6052
  Object.keys(config).map(function(key) {
6047
6053
  if (key !== "plugins") {
6048
- _this25.config[key] = config[key];
6049
- var plugin = _this25.plugins[key.toLowerCase()];
6054
+ _this26.config[key] = config[key];
6055
+ var plugin = _this26.plugins[key.toLowerCase()];
6050
6056
  if (plugin && util.typeOf(plugin.setConfig) === "Function") {
6051
6057
  plugin.setConfig(config[key]);
6052
6058
  }
@@ -6056,20 +6062,20 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6056
6062
  }, {
6057
6063
  key: "playNext",
6058
6064
  value: function playNext(config) {
6059
- var _this26 = this;
6065
+ var _this27 = this;
6060
6066
  this.resetState();
6061
6067
  this.setConfig(config);
6062
6068
  this._currentTime = 0;
6063
6069
  this._duration = 0;
6064
6070
  runHooks(this, "playnext", function() {
6065
- _this26.start();
6066
- _this26.emit(PLAYNEXT, config);
6071
+ _this27.start();
6072
+ _this27.emit(PLAYNEXT, config);
6067
6073
  });
6068
6074
  }
6069
6075
  }, {
6070
6076
  key: "resize",
6071
6077
  value: function resize() {
6072
- var _this27 = this;
6078
+ var _this28 = this;
6073
6079
  if (!this.media) {
6074
6080
  return;
6075
6081
  }
@@ -6109,7 +6115,7 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6109
6115
  }
6110
6116
  if (!this.fullscreen && !this.cssfullscreen) {
6111
6117
  Object.keys(_style).forEach(function(key) {
6112
- _this27.root.style[key] = _style[key];
6118
+ _this28.root.style[key] = _style[key];
6113
6119
  });
6114
6120
  }
6115
6121
  if (videoFillMode === "fillHeight" && fit < videoFit || videoFillMode === "fillWidth" && fit > videoFit) {
@@ -6209,15 +6215,15 @@ var Player = /* @__PURE__ */ function(_MediaProxy) {
6209
6215
  return this.config.definition.list || [];
6210
6216
  },
6211
6217
  set: function set(list) {
6212
- var _this28 = this;
6218
+ var _this29 = this;
6213
6219
  var definition = this.config.definition;
6214
6220
  var curDef = null;
6215
6221
  var targetDef = null;
6216
6222
  definition.list = list;
6217
6223
  this.emit("resourceReady", list);
6218
6224
  list.forEach(function(item) {
6219
- var _this28$curDefinition;
6220
- if (((_this28$curDefinition = _this28.curDefinition) === null || _this28$curDefinition === void 0 ? void 0 : _this28$curDefinition.definition) === item.definition) {
6225
+ var _this29$curDefinition;
6226
+ if (((_this29$curDefinition = _this29.curDefinition) === null || _this29$curDefinition === void 0 ? void 0 : _this29$curDefinition.definition) === item.definition) {
6221
6227
  curDef = item;
6222
6228
  }
6223
6229
  if (definition.defaultDefinition === item.definition) {
@@ -13277,6 +13283,40 @@ const getUrlObject = (url) => {
13277
13283
  return;
13278
13284
  }
13279
13285
  };
13286
+ function getAttributes(dom) {
13287
+ const attributes = {};
13288
+ for (const attr of dom.attributes) {
13289
+ attributes[attr.name] = attr.value;
13290
+ }
13291
+ return attributes;
13292
+ }
13293
+ function setAttributes(dom, attrs = {}) {
13294
+ Object.keys(attrs).forEach((item) => {
13295
+ const key = item;
13296
+ const value = attrs[item];
13297
+ if (value) {
13298
+ dom == null ? void 0 : dom.setAttribute(key, value);
13299
+ }
13300
+ });
13301
+ return dom;
13302
+ }
13303
+ function replaceAttributes(dom, attrs = {}) {
13304
+ const attributes = getAttributes(dom);
13305
+ Object.keys(attributes).forEach((attr) => {
13306
+ if (attrs[attr]) {
13307
+ dom == null ? void 0 : dom.setAttribute(attr, attrs[attr]);
13308
+ } else {
13309
+ dom == null ? void 0 : dom.removeAttribute(attr);
13310
+ }
13311
+ });
13312
+ return dom;
13313
+ }
13314
+ var DomUtils = /* @__PURE__ */ Object.freeze({
13315
+ __proto__: null,
13316
+ getAttributes,
13317
+ replaceAttributes,
13318
+ setAttributes
13319
+ });
13280
13320
  const H264_MIME = 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';
13281
13321
  const H265_MIME = [
13282
13322
  'video/mp4;codecs="hev1.1.6.L120.90"',
@@ -13339,6 +13379,7 @@ function isMMSSupported(codec = Codec.H264) {
13339
13379
  }
13340
13380
  ({
13341
13381
  ...util,
13382
+ ...DomUtils,
13342
13383
  getStreamType,
13343
13384
  isMseSupported,
13344
13385
  isSoftDecodeSupported,
@@ -13947,6 +13988,25 @@ class VeI18n {
13947
13988
  }
13948
13989
  }
13949
13990
  var veplayerBase = "";
13991
+ class CustomMedia {
13992
+ constructor(el) {
13993
+ __publicField(this, "_videoAttributes");
13994
+ __publicField(this, "_el");
13995
+ this._videoAttributes = getAttributes(el);
13996
+ this._el = el;
13997
+ }
13998
+ get options() {
13999
+ return {
14000
+ remainMediaAfterDestroy: true,
14001
+ mediaEl: (mediaConfig) => {
14002
+ return setAttributes(this._el, mediaConfig);
14003
+ }
14004
+ };
14005
+ }
14006
+ destroy() {
14007
+ replaceAttributes(this._el, this._videoAttributes);
14008
+ }
14009
+ }
13950
14010
  const { POSITIONS: XGPosition } = Plugin;
13951
14011
  const POSITIONS = {
13952
14012
  ...XGPosition,
@@ -14002,20 +14062,25 @@ class VePlayerBase {
14002
14062
  __publicField(this, "_previousPrepareResult");
14003
14063
  __publicField(this, "_i18nManager");
14004
14064
  __publicField(this, "_events", {});
14065
+ __publicField(this, "_customMedia");
14005
14066
  __publicField(this, "_errorCallback");
14006
- var _a, _b, _c, _d, _e;
14067
+ var _a, _b, _c, _d, _e, _f;
14007
14068
  this._sourceManager = options.sourceManager;
14008
14069
  this._preparePlugins = options.preparePlugins;
14009
14070
  this._previousPrepareResult = options.prepareResult;
14010
14071
  this._i18nManager = options.i18nManager ?? new VeI18n({
14011
14072
  i18n: options.i18n
14012
14073
  });
14074
+ if (options.mediaElement) {
14075
+ this._customMedia = new CustomMedia(options.mediaElement);
14076
+ }
14013
14077
  const xgOptions = transformOption({
14014
14078
  ...options,
14015
- ...(_a = this._previousPrepareResult) == null ? void 0 : _a.options
14079
+ ...(_a = this._customMedia) == null ? void 0 : _a.options,
14080
+ ...(_b = this._previousPrepareResult) == null ? void 0 : _b.options
14016
14081
  });
14017
14082
  const plugins = [
14018
- ...((_b = this._previousPrepareResult) == null ? void 0 : _b.plugins) ?? [],
14083
+ ...((_c = this._previousPrepareResult) == null ? void 0 : _c.plugins) ?? [],
14019
14084
  ...options.plugins ?? DEFAULT_PLUGINS
14020
14085
  ];
14021
14086
  const topRightPlugins = [];
@@ -14027,11 +14092,11 @@ class VePlayerBase {
14027
14092
  ...DEFAULT_OPTIONS,
14028
14093
  ...xgOptions,
14029
14094
  definition: {
14030
- list: ((_c = this._sourceManager.source) == null ? void 0 : _c.definitions) ?? [],
14031
- defaultDefinition: (_d = this._sourceManager.definition) == null ? void 0 : _d.definition,
14095
+ list: ((_d = this._sourceManager.source) == null ? void 0 : _d.definitions) ?? [],
14096
+ defaultDefinition: (_e = this._sourceManager.definition) == null ? void 0 : _e.definition,
14032
14097
  ...options.definition ?? {}
14033
14098
  },
14034
- url: (_e = this._sourceManager.definition) == null ? void 0 : _e.url,
14099
+ url: (_f = this._sourceManager.definition) == null ? void 0 : _f.url,
14035
14100
  sources: {
14036
14101
  ...options.sources ?? {},
14037
14102
  sourceManager: this._sourceManager
@@ -14211,7 +14276,7 @@ class VePlayerBase {
14211
14276
  * @brief Retrieve the player SDK version number.
14212
14277
  */
14213
14278
  get playerVersion() {
14214
- return "2.6.0";
14279
+ return "2.6.1-rc.0";
14215
14280
  }
14216
14281
  /** {zh}
14217
14282
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -14685,8 +14750,10 @@ class VePlayerBase {
14685
14750
  * @brief Destroys the player instance.
14686
14751
  */
14687
14752
  destroy() {
14753
+ var _a;
14688
14754
  this._player.off(ERROR, this._errorCallback);
14689
14755
  this._player.destroy();
14756
+ (_a = this._customMedia) == null ? void 0 : _a.destroy();
14690
14757
  }
14691
14758
  /** {zh}
14692
14759
  * @hidden