@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.
@@ -1461,7 +1461,7 @@ var __publicField = (obj, key, value) => {
1461
1461
  }
1462
1462
  }
1463
1463
  };
1464
- var version = "3.0.21-rc.5";
1464
+ var version = "3.0.21-alpha.13";
1465
1465
  var ERROR_TYPE_MAP = {
1466
1466
  1: "media",
1467
1467
  2: "media",
@@ -1763,7 +1763,7 @@ var __publicField = (obj, key, value) => {
1763
1763
  if (options.autoplayMuted && !Object.prototype.hasOwnProperty.call(_this.mediaConfig, "muted")) {
1764
1764
  _this.mediaConfig.muted = true;
1765
1765
  }
1766
- _this.media = util$1.createDom(_this.mediaConfig.mediaType, "", _this.mediaConfig, "");
1766
+ _this.media = options.mediaEl instanceof HTMLMediaElement ? options.mediaEl : typeof options.mediaEl === "function" ? options.mediaEl(_this.mediaConfig) : util$1.createDom(_this.mediaConfig.mediaType, "", _this.mediaConfig, "");
1767
1767
  if (options.defaultPlaybackRate) {
1768
1768
  _this.media.defaultPlaybackRate = _this.media.playbackRate = options.defaultPlaybackRate;
1769
1769
  }
@@ -1777,6 +1777,9 @@ var __publicField = (obj, key, value) => {
1777
1777
  if (options.autoplay) {
1778
1778
  _this.media.autoplay = true;
1779
1779
  }
1780
+ if (options.playsinline) {
1781
+ _this.media.playsinline = true;
1782
+ }
1780
1783
  _this._interval = {};
1781
1784
  _this.mediaEventMiddleware = {};
1782
1785
  _this.attachVideoEvents();
@@ -2497,8 +2500,9 @@ var __publicField = (obj, key, value) => {
2497
2500
  if (index !== -1) {
2498
2501
  hooks.splice(index, 1);
2499
2502
  }
2503
+ } else if (__hooks[hookName]) {
2504
+ __hooks[hookName] = null;
2500
2505
  }
2501
- delete __hooks[hookName];
2502
2506
  }
2503
2507
  function usePluginHooks(pluginName) {
2504
2508
  if (!this.plugins || !this.plugins[pluginName.toLowerCase()]) {
@@ -4754,18 +4758,10 @@ var __publicField = (obj, key, value) => {
4754
4758
  ret.destroy();
4755
4759
  }
4756
4760
  this.root.setAttribute(PLATER_ID, this.playerId);
4761
+ this.media.setAttribute(PLATER_ID, this.playerId);
4757
4762
  (_instManager = instManager) === null || _instManager === void 0 ? void 0 : _instManager.add(this);
4758
4763
  pluginsManager.init(this);
4759
4764
  this._initBaseDoms();
4760
- var XgVideoProxy = this.constructor.XgVideoProxy;
4761
- if (XgVideoProxy && this.mediaConfig.mediaType === XgVideoProxy.mediaType) {
4762
- var _el = this.innerContainer || this.root;
4763
- this.detachVideoEvents(this.media);
4764
- var _nVideo = new XgVideoProxy(_el, this.config, this.mediaConfig);
4765
- this.attachVideoEvents(_nVideo);
4766
- this.media = _nVideo;
4767
- }
4768
- this.media.setAttribute(PLATER_ID, this.playerId);
4769
4765
  if (this.config.controls) {
4770
4766
  var _root = this.config.controls.root || null;
4771
4767
  var controls = pluginsManager.register(this, Controls, {
@@ -5431,6 +5427,7 @@ var __publicField = (obj, key, value) => {
5431
5427
  this.hasStart = false;
5432
5428
  this._useAutoplay = false;
5433
5429
  root2.removeAttribute(PLATER_ID);
5430
+ media.removeAttribute(PLATER_ID);
5434
5431
  this.updateAcc("destroy");
5435
5432
  this._unbindEvents();
5436
5433
  this._detachSourceEvents(this.media);
@@ -5449,7 +5446,7 @@ var __publicField = (obj, key, value) => {
5449
5446
  innerContainer.removeChild(_c[i2]);
5450
5447
  }
5451
5448
  }
5452
- !innerContainer && media instanceof window.Node && root2.contains(media) && root2.removeChild(media);
5449
+ !innerContainer && media instanceof window.Node && root2.contains(media) && !this.config.remainMediaAfterDestroy && root2.removeChild(media);
5453
5450
  ["topBar", "leftBar", "rightBar", "innerContainer"].map(function(item) {
5454
5451
  _this18[item] && root2.removeChild(_this18[item]);
5455
5452
  _this18[item] = null;
@@ -5975,6 +5972,7 @@ var __publicField = (obj, key, value) => {
5975
5972
  }, {
5976
5973
  key: "resizePosition",
5977
5974
  value: function resizePosition() {
5975
+ var _this25 = this;
5978
5976
  var _this$videoPos = this.videoPos, vy = _this$videoPos.vy, vx = _this$videoPos.vx, h2 = _this$videoPos.h, w2 = _this$videoPos.w;
5979
5977
  var rotate = this.videoPos.rotate;
5980
5978
  if (rotate < 0 && h2 < 0 && w2 < 0) {
@@ -5999,6 +5997,7 @@ var __publicField = (obj, key, value) => {
5999
5997
  var root2 = this.root, innerContainer = this.innerContainer;
6000
5998
  var width = root2.offsetWidth;
6001
5999
  var height = innerContainer ? innerContainer.offsetHeight : root2.offsetHeight;
6000
+ var styles = {};
6002
6001
  var rHeight = height;
6003
6002
  var rWidth = width;
6004
6003
  if (_t % 2 === 0) {
@@ -6008,8 +6007,10 @@ var __publicField = (obj, key, value) => {
6008
6007
  _pos.y = _t === 2 ? 0 - offsetY : offsetY;
6009
6008
  offsetX = vx > 0 ? (100 - w2) / 2 - vx : 0;
6010
6009
  _pos.x = _t === 2 ? 0 - offsetX : offsetX;
6011
- this.media.style.width = "".concat(rWidth, "px");
6012
- this.media.style.height = "".concat(rHeight, "px");
6010
+ styles.width = "".concat(rWidth, "px");
6011
+ styles.height = "".concat(rHeight, "px");
6012
+ styles.maxWidth = "";
6013
+ styles.maxHeight = "";
6013
6014
  } else if (_t % 2 === 1) {
6014
6015
  rWidth = height;
6015
6016
  rHeight = width;
@@ -6019,12 +6020,17 @@ var __publicField = (obj, key, value) => {
6019
6020
  offsetY = offset / 2 / rHeight * 100;
6020
6021
  _pos.y = _t === 3 ? offsetY + vx / 2 : offsetY - vx / 2;
6021
6022
  _pos.scale = scale;
6022
- this.media.style.width = "".concat(rWidth, "px");
6023
- this.media.style.height = "".concat(rHeight, "px");
6023
+ styles.width = "".concat(rWidth, "px");
6024
+ styles.maxWidth = "".concat(rWidth, "px");
6025
+ styles.height = "".concat(rHeight, "px");
6026
+ styles.maxHeight = "".concat(rHeight, "px");
6024
6027
  }
6025
6028
  var formStyle = util$1.getTransformStyle(_pos, this.media.style.transform || this.media.style.webkitTransform);
6026
- this.media.style.transform = formStyle;
6027
- this.media.style.webkitTransform = formStyle;
6029
+ styles.transform = formStyle;
6030
+ styles.webkitTransform = formStyle;
6031
+ Object.keys(styles).map(function(key) {
6032
+ _this25.media.style[key] = styles[key];
6033
+ });
6028
6034
  }
6029
6035
  }, {
6030
6036
  key: "position",
@@ -6048,14 +6054,14 @@ var __publicField = (obj, key, value) => {
6048
6054
  }, {
6049
6055
  key: "setConfig",
6050
6056
  value: function setConfig(config) {
6051
- var _this25 = this;
6057
+ var _this26 = this;
6052
6058
  if (!config) {
6053
6059
  return;
6054
6060
  }
6055
6061
  Object.keys(config).map(function(key) {
6056
6062
  if (key !== "plugins") {
6057
- _this25.config[key] = config[key];
6058
- var plugin = _this25.plugins[key.toLowerCase()];
6063
+ _this26.config[key] = config[key];
6064
+ var plugin = _this26.plugins[key.toLowerCase()];
6059
6065
  if (plugin && util$1.typeOf(plugin.setConfig) === "Function") {
6060
6066
  plugin.setConfig(config[key]);
6061
6067
  }
@@ -6065,20 +6071,20 @@ var __publicField = (obj, key, value) => {
6065
6071
  }, {
6066
6072
  key: "playNext",
6067
6073
  value: function playNext(config) {
6068
- var _this26 = this;
6074
+ var _this27 = this;
6069
6075
  this.resetState();
6070
6076
  this.setConfig(config);
6071
6077
  this._currentTime = 0;
6072
6078
  this._duration = 0;
6073
6079
  runHooks(this, "playnext", function() {
6074
- _this26.start();
6075
- _this26.emit(PLAYNEXT, config);
6080
+ _this27.start();
6081
+ _this27.emit(PLAYNEXT, config);
6076
6082
  });
6077
6083
  }
6078
6084
  }, {
6079
6085
  key: "resize",
6080
6086
  value: function resize() {
6081
- var _this27 = this;
6087
+ var _this28 = this;
6082
6088
  if (!this.media) {
6083
6089
  return;
6084
6090
  }
@@ -6118,7 +6124,7 @@ var __publicField = (obj, key, value) => {
6118
6124
  }
6119
6125
  if (!this.fullscreen && !this.cssfullscreen) {
6120
6126
  Object.keys(_style).forEach(function(key) {
6121
- _this27.root.style[key] = _style[key];
6127
+ _this28.root.style[key] = _style[key];
6122
6128
  });
6123
6129
  }
6124
6130
  if (videoFillMode === "fillHeight" && fit < videoFit || videoFillMode === "fillWidth" && fit > videoFit) {
@@ -6218,15 +6224,15 @@ var __publicField = (obj, key, value) => {
6218
6224
  return this.config.definition.list || [];
6219
6225
  },
6220
6226
  set: function set(list) {
6221
- var _this28 = this;
6227
+ var _this29 = this;
6222
6228
  var definition = this.config.definition;
6223
6229
  var curDef = null;
6224
6230
  var targetDef = null;
6225
6231
  definition.list = list;
6226
6232
  this.emit("resourceReady", list);
6227
6233
  list.forEach(function(item) {
6228
- var _this28$curDefinition;
6229
- if (((_this28$curDefinition = _this28.curDefinition) === null || _this28$curDefinition === void 0 ? void 0 : _this28$curDefinition.definition) === item.definition) {
6234
+ var _this29$curDefinition;
6235
+ if (((_this29$curDefinition = _this29.curDefinition) === null || _this29$curDefinition === void 0 ? void 0 : _this29$curDefinition.definition) === item.definition) {
6230
6236
  curDef = item;
6231
6237
  }
6232
6238
  if (definition.defaultDefinition === item.definition) {
@@ -13390,6 +13396,40 @@ var __publicField = (obj, key, value) => {
13390
13396
  return;
13391
13397
  }
13392
13398
  };
13399
+ function getAttributes(dom) {
13400
+ const attributes = {};
13401
+ for (const attr of dom.attributes) {
13402
+ attributes[attr.name] = attr.value;
13403
+ }
13404
+ return attributes;
13405
+ }
13406
+ function setAttributes(dom, attrs = {}) {
13407
+ Object.keys(attrs).forEach((item) => {
13408
+ const key = item;
13409
+ const value = attrs[item];
13410
+ if (value) {
13411
+ dom == null ? void 0 : dom.setAttribute(key, value);
13412
+ }
13413
+ });
13414
+ return dom;
13415
+ }
13416
+ function replaceAttributes(dom, attrs = {}) {
13417
+ const attributes = getAttributes(dom);
13418
+ Object.keys(attributes).forEach((attr) => {
13419
+ if (attrs[attr]) {
13420
+ dom == null ? void 0 : dom.setAttribute(attr, attrs[attr]);
13421
+ } else {
13422
+ dom == null ? void 0 : dom.removeAttribute(attr);
13423
+ }
13424
+ });
13425
+ return dom;
13426
+ }
13427
+ var DomUtils = /* @__PURE__ */ Object.freeze({
13428
+ __proto__: null,
13429
+ getAttributes,
13430
+ replaceAttributes,
13431
+ setAttributes
13432
+ });
13393
13433
  const H264_MIME = 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';
13394
13434
  const H265_MIME = [
13395
13435
  'video/mp4;codecs="hev1.1.6.L120.90"',
@@ -13452,6 +13492,7 @@ var __publicField = (obj, key, value) => {
13452
13492
  }
13453
13493
  const util = {
13454
13494
  ...util$1,
13495
+ ...DomUtils,
13455
13496
  getStreamType,
13456
13497
  isMseSupported: isMseSupported$2,
13457
13498
  isSoftDecodeSupported: isSoftDecodeSupported$1,
@@ -14114,6 +14155,25 @@ var __publicField = (obj, key, value) => {
14114
14155
  }
14115
14156
  }
14116
14157
  var veplayerBase = "";
14158
+ class CustomMedia {
14159
+ constructor(el) {
14160
+ __publicField(this, "_videoAttributes");
14161
+ __publicField(this, "_el");
14162
+ this._videoAttributes = getAttributes(el);
14163
+ this._el = el;
14164
+ }
14165
+ get options() {
14166
+ return {
14167
+ remainMediaAfterDestroy: true,
14168
+ mediaEl: (mediaConfig) => {
14169
+ return setAttributes(this._el, mediaConfig);
14170
+ }
14171
+ };
14172
+ }
14173
+ destroy() {
14174
+ replaceAttributes(this._el, this._videoAttributes);
14175
+ }
14176
+ }
14117
14177
  const { POSITIONS: XGPosition } = Plugin;
14118
14178
  const POSITIONS$1 = {
14119
14179
  ...XGPosition,
@@ -14169,20 +14229,25 @@ var __publicField = (obj, key, value) => {
14169
14229
  __publicField(this, "_previousPrepareResult");
14170
14230
  __publicField(this, "_i18nManager");
14171
14231
  __publicField(this, "_events", {});
14232
+ __publicField(this, "_customMedia");
14172
14233
  __publicField(this, "_errorCallback");
14173
- var _a, _b, _c, _d, _e;
14234
+ var _a, _b, _c, _d, _e, _f;
14174
14235
  this._sourceManager = options.sourceManager;
14175
14236
  this._preparePlugins = options.preparePlugins;
14176
14237
  this._previousPrepareResult = options.prepareResult;
14177
14238
  this._i18nManager = options.i18nManager ?? new VeI18n({
14178
14239
  i18n: options.i18n
14179
14240
  });
14241
+ if (options.mediaElement) {
14242
+ this._customMedia = new CustomMedia(options.mediaElement);
14243
+ }
14180
14244
  const xgOptions = transformOption({
14181
14245
  ...options,
14182
- ...(_a = this._previousPrepareResult) == null ? void 0 : _a.options
14246
+ ...(_a = this._customMedia) == null ? void 0 : _a.options,
14247
+ ...(_b = this._previousPrepareResult) == null ? void 0 : _b.options
14183
14248
  });
14184
14249
  const plugins = [
14185
- ...((_b = this._previousPrepareResult) == null ? void 0 : _b.plugins) ?? [],
14250
+ ...((_c = this._previousPrepareResult) == null ? void 0 : _c.plugins) ?? [],
14186
14251
  ...options.plugins ?? DEFAULT_PLUGINS
14187
14252
  ];
14188
14253
  const topRightPlugins = [];
@@ -14194,11 +14259,11 @@ var __publicField = (obj, key, value) => {
14194
14259
  ...DEFAULT_OPTIONS,
14195
14260
  ...xgOptions,
14196
14261
  definition: {
14197
- list: ((_c = this._sourceManager.source) == null ? void 0 : _c.definitions) ?? [],
14198
- defaultDefinition: (_d = this._sourceManager.definition) == null ? void 0 : _d.definition,
14262
+ list: ((_d = this._sourceManager.source) == null ? void 0 : _d.definitions) ?? [],
14263
+ defaultDefinition: (_e = this._sourceManager.definition) == null ? void 0 : _e.definition,
14199
14264
  ...options.definition ?? {}
14200
14265
  },
14201
- url: (_e = this._sourceManager.definition) == null ? void 0 : _e.url,
14266
+ url: (_f = this._sourceManager.definition) == null ? void 0 : _f.url,
14202
14267
  sources: {
14203
14268
  ...options.sources ?? {},
14204
14269
  sourceManager: this._sourceManager
@@ -14378,7 +14443,7 @@ var __publicField = (obj, key, value) => {
14378
14443
  * @brief Retrieve the player SDK version number.
14379
14444
  */
14380
14445
  get playerVersion() {
14381
- return "2.6.0";
14446
+ return "2.6.1-rc.0";
14382
14447
  }
14383
14448
  /** {zh}
14384
14449
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -14852,8 +14917,10 @@ var __publicField = (obj, key, value) => {
14852
14917
  * @brief Destroys the player instance.
14853
14918
  */
14854
14919
  destroy() {
14920
+ var _a;
14855
14921
  this._player.off(ERROR, this._errorCallback);
14856
14922
  this._player.destroy();
14923
+ (_a = this._customMedia) == null ? void 0 : _a.destroy();
14857
14924
  }
14858
14925
  /** {zh}
14859
14926
  * @hidden
@@ -22743,9 +22810,9 @@ var __publicField = (obj, key, value) => {
22743
22810
  device_id: this._deviceId,
22744
22811
  error_report_stop: true,
22745
22812
  ext: {
22746
- veplayer_version: "2.6.0",
22813
+ veplayer_version: "2.6.1-rc.0",
22747
22814
  flv_version: "3.0.21-rc.5",
22748
- hls_version: "3.0.21-rc.5",
22815
+ hls_version: "3.0.21-rc.20",
22749
22816
  rts_version: "0.2.1-alpha.14"
22750
22817
  }
22751
22818
  });