@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
@@ -1456,7 +1456,7 @@ var __publicField = (obj, key, value) => {
1456
1456
  }
1457
1457
  }
1458
1458
  };
1459
- var version = "3.0.21-rc.5";
1459
+ var version = "3.0.21-alpha.13";
1460
1460
  var ERROR_TYPE_MAP = {
1461
1461
  1: "media",
1462
1462
  2: "media",
@@ -1758,7 +1758,7 @@ var __publicField = (obj, key, value) => {
1758
1758
  if (options.autoplayMuted && !Object.prototype.hasOwnProperty.call(_this.mediaConfig, "muted")) {
1759
1759
  _this.mediaConfig.muted = true;
1760
1760
  }
1761
- _this.media = util.createDom(_this.mediaConfig.mediaType, "", _this.mediaConfig, "");
1761
+ _this.media = options.mediaEl instanceof HTMLMediaElement ? options.mediaEl : typeof options.mediaEl === "function" ? options.mediaEl(_this.mediaConfig) : util.createDom(_this.mediaConfig.mediaType, "", _this.mediaConfig, "");
1762
1762
  if (options.defaultPlaybackRate) {
1763
1763
  _this.media.defaultPlaybackRate = _this.media.playbackRate = options.defaultPlaybackRate;
1764
1764
  }
@@ -1772,6 +1772,9 @@ var __publicField = (obj, key, value) => {
1772
1772
  if (options.autoplay) {
1773
1773
  _this.media.autoplay = true;
1774
1774
  }
1775
+ if (options.playsinline) {
1776
+ _this.media.playsinline = true;
1777
+ }
1775
1778
  _this._interval = {};
1776
1779
  _this.mediaEventMiddleware = {};
1777
1780
  _this.attachVideoEvents();
@@ -2492,8 +2495,9 @@ var __publicField = (obj, key, value) => {
2492
2495
  if (index !== -1) {
2493
2496
  hooks.splice(index, 1);
2494
2497
  }
2498
+ } else if (__hooks[hookName]) {
2499
+ __hooks[hookName] = null;
2495
2500
  }
2496
- delete __hooks[hookName];
2497
2501
  }
2498
2502
  function usePluginHooks(pluginName) {
2499
2503
  if (!this.plugins || !this.plugins[pluginName.toLowerCase()]) {
@@ -4749,18 +4753,10 @@ var __publicField = (obj, key, value) => {
4749
4753
  ret.destroy();
4750
4754
  }
4751
4755
  this.root.setAttribute(PLATER_ID, this.playerId);
4756
+ this.media.setAttribute(PLATER_ID, this.playerId);
4752
4757
  (_instManager = instManager) === null || _instManager === void 0 ? void 0 : _instManager.add(this);
4753
4758
  pluginsManager.init(this);
4754
4759
  this._initBaseDoms();
4755
- var XgVideoProxy = this.constructor.XgVideoProxy;
4756
- if (XgVideoProxy && this.mediaConfig.mediaType === XgVideoProxy.mediaType) {
4757
- var _el = this.innerContainer || this.root;
4758
- this.detachVideoEvents(this.media);
4759
- var _nVideo = new XgVideoProxy(_el, this.config, this.mediaConfig);
4760
- this.attachVideoEvents(_nVideo);
4761
- this.media = _nVideo;
4762
- }
4763
- this.media.setAttribute(PLATER_ID, this.playerId);
4764
4760
  if (this.config.controls) {
4765
4761
  var _root = this.config.controls.root || null;
4766
4762
  var controls = pluginsManager.register(this, Controls, {
@@ -5426,6 +5422,7 @@ var __publicField = (obj, key, value) => {
5426
5422
  this.hasStart = false;
5427
5423
  this._useAutoplay = false;
5428
5424
  root2.removeAttribute(PLATER_ID);
5425
+ media.removeAttribute(PLATER_ID);
5429
5426
  this.updateAcc("destroy");
5430
5427
  this._unbindEvents();
5431
5428
  this._detachSourceEvents(this.media);
@@ -5444,7 +5441,7 @@ var __publicField = (obj, key, value) => {
5444
5441
  innerContainer.removeChild(_c[i]);
5445
5442
  }
5446
5443
  }
5447
- !innerContainer && media instanceof window.Node && root2.contains(media) && root2.removeChild(media);
5444
+ !innerContainer && media instanceof window.Node && root2.contains(media) && !this.config.remainMediaAfterDestroy && root2.removeChild(media);
5448
5445
  ["topBar", "leftBar", "rightBar", "innerContainer"].map(function(item) {
5449
5446
  _this18[item] && root2.removeChild(_this18[item]);
5450
5447
  _this18[item] = null;
@@ -5970,6 +5967,7 @@ var __publicField = (obj, key, value) => {
5970
5967
  }, {
5971
5968
  key: "resizePosition",
5972
5969
  value: function resizePosition() {
5970
+ var _this25 = this;
5973
5971
  var _this$videoPos = this.videoPos, vy = _this$videoPos.vy, vx = _this$videoPos.vx, h = _this$videoPos.h, w = _this$videoPos.w;
5974
5972
  var rotate = this.videoPos.rotate;
5975
5973
  if (rotate < 0 && h < 0 && w < 0) {
@@ -5994,6 +5992,7 @@ var __publicField = (obj, key, value) => {
5994
5992
  var root2 = this.root, innerContainer = this.innerContainer;
5995
5993
  var width = root2.offsetWidth;
5996
5994
  var height = innerContainer ? innerContainer.offsetHeight : root2.offsetHeight;
5995
+ var styles = {};
5997
5996
  var rHeight = height;
5998
5997
  var rWidth = width;
5999
5998
  if (_t % 2 === 0) {
@@ -6003,8 +6002,10 @@ var __publicField = (obj, key, value) => {
6003
6002
  _pos.y = _t === 2 ? 0 - offsetY : offsetY;
6004
6003
  offsetX = vx > 0 ? (100 - w) / 2 - vx : 0;
6005
6004
  _pos.x = _t === 2 ? 0 - offsetX : offsetX;
6006
- this.media.style.width = "".concat(rWidth, "px");
6007
- this.media.style.height = "".concat(rHeight, "px");
6005
+ styles.width = "".concat(rWidth, "px");
6006
+ styles.height = "".concat(rHeight, "px");
6007
+ styles.maxWidth = "";
6008
+ styles.maxHeight = "";
6008
6009
  } else if (_t % 2 === 1) {
6009
6010
  rWidth = height;
6010
6011
  rHeight = width;
@@ -6014,12 +6015,17 @@ var __publicField = (obj, key, value) => {
6014
6015
  offsetY = offset / 2 / rHeight * 100;
6015
6016
  _pos.y = _t === 3 ? offsetY + vx / 2 : offsetY - vx / 2;
6016
6017
  _pos.scale = scale;
6017
- this.media.style.width = "".concat(rWidth, "px");
6018
- this.media.style.height = "".concat(rHeight, "px");
6018
+ styles.width = "".concat(rWidth, "px");
6019
+ styles.maxWidth = "".concat(rWidth, "px");
6020
+ styles.height = "".concat(rHeight, "px");
6021
+ styles.maxHeight = "".concat(rHeight, "px");
6019
6022
  }
6020
6023
  var formStyle = util.getTransformStyle(_pos, this.media.style.transform || this.media.style.webkitTransform);
6021
- this.media.style.transform = formStyle;
6022
- this.media.style.webkitTransform = formStyle;
6024
+ styles.transform = formStyle;
6025
+ styles.webkitTransform = formStyle;
6026
+ Object.keys(styles).map(function(key) {
6027
+ _this25.media.style[key] = styles[key];
6028
+ });
6023
6029
  }
6024
6030
  }, {
6025
6031
  key: "position",
@@ -6043,14 +6049,14 @@ var __publicField = (obj, key, value) => {
6043
6049
  }, {
6044
6050
  key: "setConfig",
6045
6051
  value: function setConfig(config) {
6046
- var _this25 = this;
6052
+ var _this26 = this;
6047
6053
  if (!config) {
6048
6054
  return;
6049
6055
  }
6050
6056
  Object.keys(config).map(function(key) {
6051
6057
  if (key !== "plugins") {
6052
- _this25.config[key] = config[key];
6053
- var plugin = _this25.plugins[key.toLowerCase()];
6058
+ _this26.config[key] = config[key];
6059
+ var plugin = _this26.plugins[key.toLowerCase()];
6054
6060
  if (plugin && util.typeOf(plugin.setConfig) === "Function") {
6055
6061
  plugin.setConfig(config[key]);
6056
6062
  }
@@ -6060,20 +6066,20 @@ var __publicField = (obj, key, value) => {
6060
6066
  }, {
6061
6067
  key: "playNext",
6062
6068
  value: function playNext(config) {
6063
- var _this26 = this;
6069
+ var _this27 = this;
6064
6070
  this.resetState();
6065
6071
  this.setConfig(config);
6066
6072
  this._currentTime = 0;
6067
6073
  this._duration = 0;
6068
6074
  runHooks(this, "playnext", function() {
6069
- _this26.start();
6070
- _this26.emit(PLAYNEXT, config);
6075
+ _this27.start();
6076
+ _this27.emit(PLAYNEXT, config);
6071
6077
  });
6072
6078
  }
6073
6079
  }, {
6074
6080
  key: "resize",
6075
6081
  value: function resize() {
6076
- var _this27 = this;
6082
+ var _this28 = this;
6077
6083
  if (!this.media) {
6078
6084
  return;
6079
6085
  }
@@ -6113,7 +6119,7 @@ var __publicField = (obj, key, value) => {
6113
6119
  }
6114
6120
  if (!this.fullscreen && !this.cssfullscreen) {
6115
6121
  Object.keys(_style).forEach(function(key) {
6116
- _this27.root.style[key] = _style[key];
6122
+ _this28.root.style[key] = _style[key];
6117
6123
  });
6118
6124
  }
6119
6125
  if (videoFillMode === "fillHeight" && fit < videoFit || videoFillMode === "fillWidth" && fit > videoFit) {
@@ -6213,15 +6219,15 @@ var __publicField = (obj, key, value) => {
6213
6219
  return this.config.definition.list || [];
6214
6220
  },
6215
6221
  set: function set(list) {
6216
- var _this28 = this;
6222
+ var _this29 = this;
6217
6223
  var definition = this.config.definition;
6218
6224
  var curDef = null;
6219
6225
  var targetDef = null;
6220
6226
  definition.list = list;
6221
6227
  this.emit("resourceReady", list);
6222
6228
  list.forEach(function(item) {
6223
- var _this28$curDefinition;
6224
- if (((_this28$curDefinition = _this28.curDefinition) === null || _this28$curDefinition === void 0 ? void 0 : _this28$curDefinition.definition) === item.definition) {
6229
+ var _this29$curDefinition;
6230
+ if (((_this29$curDefinition = _this29.curDefinition) === null || _this29$curDefinition === void 0 ? void 0 : _this29$curDefinition.definition) === item.definition) {
6225
6231
  curDef = item;
6226
6232
  }
6227
6233
  if (definition.defaultDefinition === item.definition) {
@@ -13281,6 +13287,40 @@ var __publicField = (obj, key, value) => {
13281
13287
  return;
13282
13288
  }
13283
13289
  };
13290
+ function getAttributes(dom) {
13291
+ const attributes = {};
13292
+ for (const attr of dom.attributes) {
13293
+ attributes[attr.name] = attr.value;
13294
+ }
13295
+ return attributes;
13296
+ }
13297
+ function setAttributes(dom, attrs = {}) {
13298
+ Object.keys(attrs).forEach((item) => {
13299
+ const key = item;
13300
+ const value = attrs[item];
13301
+ if (value) {
13302
+ dom == null ? void 0 : dom.setAttribute(key, value);
13303
+ }
13304
+ });
13305
+ return dom;
13306
+ }
13307
+ function replaceAttributes(dom, attrs = {}) {
13308
+ const attributes = getAttributes(dom);
13309
+ Object.keys(attributes).forEach((attr) => {
13310
+ if (attrs[attr]) {
13311
+ dom == null ? void 0 : dom.setAttribute(attr, attrs[attr]);
13312
+ } else {
13313
+ dom == null ? void 0 : dom.removeAttribute(attr);
13314
+ }
13315
+ });
13316
+ return dom;
13317
+ }
13318
+ var DomUtils = /* @__PURE__ */ Object.freeze({
13319
+ __proto__: null,
13320
+ getAttributes,
13321
+ replaceAttributes,
13322
+ setAttributes
13323
+ });
13284
13324
  const H264_MIME = 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';
13285
13325
  const H265_MIME = [
13286
13326
  'video/mp4;codecs="hev1.1.6.L120.90"',
@@ -13343,6 +13383,7 @@ var __publicField = (obj, key, value) => {
13343
13383
  }
13344
13384
  ({
13345
13385
  ...util,
13386
+ ...DomUtils,
13346
13387
  getStreamType,
13347
13388
  isMseSupported,
13348
13389
  isSoftDecodeSupported,
@@ -13951,6 +13992,25 @@ var __publicField = (obj, key, value) => {
13951
13992
  }
13952
13993
  }
13953
13994
  var veplayerBase = "";
13995
+ class CustomMedia {
13996
+ constructor(el) {
13997
+ __publicField(this, "_videoAttributes");
13998
+ __publicField(this, "_el");
13999
+ this._videoAttributes = getAttributes(el);
14000
+ this._el = el;
14001
+ }
14002
+ get options() {
14003
+ return {
14004
+ remainMediaAfterDestroy: true,
14005
+ mediaEl: (mediaConfig) => {
14006
+ return setAttributes(this._el, mediaConfig);
14007
+ }
14008
+ };
14009
+ }
14010
+ destroy() {
14011
+ replaceAttributes(this._el, this._videoAttributes);
14012
+ }
14013
+ }
13954
14014
  const { POSITIONS: XGPosition } = Plugin;
13955
14015
  const POSITIONS = {
13956
14016
  ...XGPosition,
@@ -14006,20 +14066,25 @@ var __publicField = (obj, key, value) => {
14006
14066
  __publicField(this, "_previousPrepareResult");
14007
14067
  __publicField(this, "_i18nManager");
14008
14068
  __publicField(this, "_events", {});
14069
+ __publicField(this, "_customMedia");
14009
14070
  __publicField(this, "_errorCallback");
14010
- var _a, _b, _c, _d, _e;
14071
+ var _a, _b, _c, _d, _e, _f;
14011
14072
  this._sourceManager = options.sourceManager;
14012
14073
  this._preparePlugins = options.preparePlugins;
14013
14074
  this._previousPrepareResult = options.prepareResult;
14014
14075
  this._i18nManager = options.i18nManager ?? new VeI18n({
14015
14076
  i18n: options.i18n
14016
14077
  });
14078
+ if (options.mediaElement) {
14079
+ this._customMedia = new CustomMedia(options.mediaElement);
14080
+ }
14017
14081
  const xgOptions = transformOption({
14018
14082
  ...options,
14019
- ...(_a = this._previousPrepareResult) == null ? void 0 : _a.options
14083
+ ...(_a = this._customMedia) == null ? void 0 : _a.options,
14084
+ ...(_b = this._previousPrepareResult) == null ? void 0 : _b.options
14020
14085
  });
14021
14086
  const plugins = [
14022
- ...((_b = this._previousPrepareResult) == null ? void 0 : _b.plugins) ?? [],
14087
+ ...((_c = this._previousPrepareResult) == null ? void 0 : _c.plugins) ?? [],
14023
14088
  ...options.plugins ?? DEFAULT_PLUGINS
14024
14089
  ];
14025
14090
  const topRightPlugins = [];
@@ -14031,11 +14096,11 @@ var __publicField = (obj, key, value) => {
14031
14096
  ...DEFAULT_OPTIONS,
14032
14097
  ...xgOptions,
14033
14098
  definition: {
14034
- list: ((_c = this._sourceManager.source) == null ? void 0 : _c.definitions) ?? [],
14035
- defaultDefinition: (_d = this._sourceManager.definition) == null ? void 0 : _d.definition,
14099
+ list: ((_d = this._sourceManager.source) == null ? void 0 : _d.definitions) ?? [],
14100
+ defaultDefinition: (_e = this._sourceManager.definition) == null ? void 0 : _e.definition,
14036
14101
  ...options.definition ?? {}
14037
14102
  },
14038
- url: (_e = this._sourceManager.definition) == null ? void 0 : _e.url,
14103
+ url: (_f = this._sourceManager.definition) == null ? void 0 : _f.url,
14039
14104
  sources: {
14040
14105
  ...options.sources ?? {},
14041
14106
  sourceManager: this._sourceManager
@@ -14215,7 +14280,7 @@ var __publicField = (obj, key, value) => {
14215
14280
  * @brief Retrieve the player SDK version number.
14216
14281
  */
14217
14282
  get playerVersion() {
14218
- return "2.6.0";
14283
+ return "2.6.1-rc.0";
14219
14284
  }
14220
14285
  /** {zh}
14221
14286
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -14689,8 +14754,10 @@ var __publicField = (obj, key, value) => {
14689
14754
  * @brief Destroys the player instance.
14690
14755
  */
14691
14756
  destroy() {
14757
+ var _a;
14692
14758
  this._player.off(ERROR, this._errorCallback);
14693
14759
  this._player.destroy();
14760
+ (_a = this._customMedia) == null ? void 0 : _a.destroy();
14694
14761
  }
14695
14762
  /** {zh}
14696
14763
  * @hidden