@volcengine/veplayer 2.5.0 → 2.5.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.
@@ -1461,7 +1461,7 @@ var __publicField = (obj, key, value) => {
1461
1461
  }
1462
1462
  }
1463
1463
  };
1464
- var version = "3.0.21-rc.2";
1464
+ var version = "3.0.21-rc.5";
1465
1465
  var ERROR_TYPE_MAP = {
1466
1466
  1: "media",
1467
1467
  2: "media",
@@ -1917,7 +1917,7 @@ var __publicField = (obj, key, value) => {
1917
1917
  var _e = this.media.error || error2;
1918
1918
  var type = _e.code ? ERROR_TYPE_MAP[_e.code] : "other";
1919
1919
  var message = _e.message;
1920
- if (!this.media.currentSrc) {
1920
+ if (!(this.media.currentSrc || this.media.srcObject)) {
1921
1921
  message = "empty_src";
1922
1922
  _e = {
1923
1923
  code: 6,
@@ -4131,6 +4131,10 @@ var __publicField = (obj, key, value) => {
4131
4131
  this.unbind("mouseenter", this.onMouseEnter);
4132
4132
  this.unbind("mouseleave", this.onMouseLeave);
4133
4133
  }
4134
+ this.left = null;
4135
+ this.center = null;
4136
+ this.right = null;
4137
+ this.innerRoot = null;
4134
4138
  }
4135
4139
  }, {
4136
4140
  key: "render",
@@ -12844,7 +12848,7 @@ var __publicField = (obj, key, value) => {
12844
12848
  });
12845
12849
  }
12846
12850
  }
12847
- const appendSearchParams = (url, searchParams) => {
12851
+ const appendSearchParams$1 = (url, searchParams) => {
12848
12852
  var _a, _b;
12849
12853
  const urlObject = getUrlObject(url);
12850
12854
  if (!url || !urlObject) {
@@ -12879,6 +12883,13 @@ var __publicField = (obj, key, value) => {
12879
12883
  return;
12880
12884
  }
12881
12885
  };
12886
+ const H264_MIME = 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';
12887
+ const H265_MIME = [
12888
+ 'video/mp4;codecs="hev1.1.6.L120.90"',
12889
+ 'video/mp4;codecs="hev1.2.4.L120.90"',
12890
+ 'video/mp4;codecs="hev1.3.E.L120.90"',
12891
+ 'video/mp4;codecs="hev1.4.10.L120.90"'
12892
+ ];
12882
12893
  function isType(suffix) {
12883
12894
  return function(url) {
12884
12895
  return url == null ? void 0 : url.split("?")[0].toLowerCase().includes(suffix);
@@ -12907,26 +12918,40 @@ var __publicField = (obj, key, value) => {
12907
12918
  }
12908
12919
  return "unknown";
12909
12920
  }
12910
- function isMseSupported$1(codec = Codec.H264) {
12921
+ function isMseSupported$2(codec = Codec.H264) {
12911
12922
  if (codec === Codec.H265) {
12912
12923
  return sniffer$1.isHevcSupported();
12913
12924
  }
12914
- return sniffer$1.isMSESupport();
12925
+ if (codec === Codec.H264) {
12926
+ return sniffer$1.isMSESupport();
12927
+ }
12928
+ return sniffer$1.isMSESupport(codec);
12915
12929
  }
12916
12930
  async function isSoftDecodeSupported$1() {
12917
12931
  const { XGVideoPlugin } = await load(DynamicModule.PluginXgvideo);
12918
12932
  return XGVideoPlugin == null ? void 0 : XGVideoPlugin.isSupported();
12919
12933
  }
12920
- function isMMSSupported$1() {
12921
- return typeof ManagedMediaSource !== "undefined";
12934
+ function isMMSSupported$2(codec = Codec.H264) {
12935
+ if (typeof window.ManagedMediaSource === "undefined") {
12936
+ return false;
12937
+ }
12938
+ if (codec === Codec.H264) {
12939
+ return window.ManagedMediaSource.isTypeSupported(H264_MIME);
12940
+ }
12941
+ if (codec === Codec.H265) {
12942
+ return H265_MIME.some((mine) => {
12943
+ return window.ManagedMediaSource.isTypeSupported(mine);
12944
+ });
12945
+ }
12946
+ return window.ManagedMediaSource.isTypeSupported(codec);
12922
12947
  }
12923
12948
  const util = {
12924
12949
  ...util$1,
12925
12950
  getStreamType,
12926
- isMseSupported: isMseSupported$1,
12951
+ isMseSupported: isMseSupported$2,
12927
12952
  isSoftDecodeSupported: isSoftDecodeSupported$1,
12928
- isMMSSupported: isMMSSupported$1,
12929
- appendSearchParams,
12953
+ isMMSSupported: isMMSSupported$2,
12954
+ appendSearchParams: appendSearchParams$1,
12930
12955
  getUrlObject
12931
12956
  };
12932
12957
  var autoplay = "";
@@ -13847,7 +13872,7 @@ var __publicField = (obj, key, value) => {
13847
13872
  * @brief Retrieve the player SDK version number.
13848
13873
  */
13849
13874
  get playerVersion() {
13850
- return "2.5.0";
13875
+ return "2.5.1-rc.1";
13851
13876
  }
13852
13877
  /** {zh}
13853
13878
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -18968,48 +18993,6 @@ var __publicField = (obj, key, value) => {
18968
18993
  return result;
18969
18994
  }
18970
18995
  }
18971
- const getFlvStrategy = async (options) => {
18972
- var _a, _b, _c, _d, _e, _f;
18973
- let mseStrategy;
18974
- let softStrategy;
18975
- const enableLowLatency = ((_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.enableLowLatency) && sniffer$1.device === "pc";
18976
- const enableFrameChasing = ((_c = (_b = options == null ? void 0 : options.flv) == null ? void 0 : _b.lowLatency) == null ? void 0 : _c.enableFrameChasing) ?? true;
18977
- const abrPts = ((_e = (_d = options == null ? void 0 : options.flv) == null ? void 0 : _d.lowLatency) == null ? void 0 : _e.abrPts) ?? "-800";
18978
- const codec = await getCodec(options);
18979
- const isSoftDecode$1 = await isSoftDecode(options, codec);
18980
- if (isSoftDecode$1) {
18981
- softStrategy = codec === Codec.H265 ? createSoftDecodeH265Strategy() : createSoftDecodeH264Strategy();
18982
- mseStrategy = createFlvMseStrategy(options);
18983
- }
18984
- if (codec === "unknown" ? isMseSupported$1(Codec.H264) : isMseSupported$1(codec)) {
18985
- mseStrategy = createFlvMseStrategy(options);
18986
- } else if (isMMSSupported$1()) {
18987
- mseStrategy = createFlvMssStrategy(options);
18988
- }
18989
- if (!mseStrategy && !softStrategy) {
18990
- return {};
18991
- }
18992
- const [mseModule, softModule] = await Promise.all([
18993
- (mseStrategy == null ? void 0 : mseStrategy.module) && load(mseStrategy.module).catch(() => void 0),
18994
- (softStrategy == null ? void 0 : softStrategy.module) && load(softStrategy.module).catch(() => void 0)
18995
- ]);
18996
- (softModule == null ? void 0 : softModule.XGVideoPlugin) && ((_f = softStrategy == null ? void 0 : softStrategy.afterLoad) == null ? void 0 : _f.call(softStrategy, softModule == null ? void 0 : softModule.XGVideoPlugin));
18997
- const combineOptions$1 = combineOptions([mseStrategy, softStrategy]);
18998
- const plugins = [];
18999
- if (enableLowLatency) {
19000
- combineOptions$1.url = appendSearchParams(options.url, { abr_pts: abrPts });
19001
- }
19002
- if (mseModule) {
19003
- plugins.push(mseModule.FlvPlugin);
19004
- if (enableLowLatency && enableFrameChasing) {
19005
- plugins.push(mseModule.Adaptive);
19006
- }
19007
- }
19008
- return {
19009
- options: combineOptions$1,
19010
- plugins
19011
- };
19012
- };
19013
18996
  const getHlsStrategy = async (options) => {
19014
18997
  var _a, _b;
19015
18998
  let mseStrategy;
@@ -19020,7 +19003,7 @@ var __publicField = (obj, key, value) => {
19020
19003
  softStrategy = codec === Codec.H265 ? createSoftDecodeH265Strategy() : createSoftDecodeH264Strategy();
19021
19004
  mseStrategy = createHlsMseStrategy(options);
19022
19005
  }
19023
- if ((sniffer$1.device !== "mobile" || ((_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.enableMSE)) && (codec === "unknown" ? isMseSupported$1(Codec.H264) : isMseSupported$1(codec))) {
19006
+ if ((sniffer$1.device !== "mobile" || ((_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.enableMSE)) && (codec === "unknown" ? isMseSupported$2(Codec.H264) : isMseSupported$2(codec))) {
19024
19007
  mseStrategy = createHlsMseStrategy(options);
19025
19008
  }
19026
19009
  if (!mseStrategy && !softStrategy) {
@@ -19167,6 +19150,7 @@ var __publicField = (obj, key, value) => {
19167
19150
  const { VeError } = error$1;
19168
19151
  var LiveErrorCode = /* @__PURE__ */ ((LiveErrorCode2) => {
19169
19152
  LiveErrorCode2[LiveErrorCode2["INVALID_PARAMETER"] = 210] = "INVALID_PARAMETER";
19153
+ LiveErrorCode2[LiveErrorCode2["INVALID_LOGGER"] = 220] = "INVALID_LOGGER";
19170
19154
  return LiveErrorCode2;
19171
19155
  })(LiveErrorCode || {});
19172
19156
  const ErrorCode = {
@@ -19181,10 +19165,23 @@ var __publicField = (obj, key, value) => {
19181
19165
  ]: {
19182
19166
  messageTextKey: "INVALID_PARAMETER",
19183
19167
  level: Level.Fatal
19168
+ },
19169
+ [
19170
+ 220
19171
+ /* INVALID_LOGGER */
19172
+ ]: {
19173
+ messageTextKey: "INVALID_LOGGER",
19174
+ level: Level.Error
19184
19175
  }
19185
19176
  };
19186
19177
  function create(errorCode, i18n) {
19187
- return new VeError(ERRORS[errorCode], i18n);
19178
+ return new VeError(
19179
+ {
19180
+ errorCode,
19181
+ ...ERRORS[errorCode]
19182
+ },
19183
+ i18n
19184
+ );
19188
19185
  }
19189
19186
  async function isRTMSupported() {
19190
19187
  const { RtmPlugin } = await load(DynamicModule.PluginRtm);
@@ -19302,6 +19299,55 @@ var __publicField = (obj, key, value) => {
19302
19299
  }
19303
19300
  return true;
19304
19301
  }
19302
+ const { isMMSSupported: isMMSSupported$1, isMseSupported: isMseSupported$1 } = util;
19303
+ function enableMMS() {
19304
+ return sniffer$1.os.isIos;
19305
+ }
19306
+ function isFLVSupported$1(codec = Codec.H264) {
19307
+ const isMediaSourceSupported = enableMMS() ? isMMSSupported$1 : isMseSupported$1;
19308
+ return isMediaSourceSupported(codec);
19309
+ }
19310
+ const { appendSearchParams } = util;
19311
+ const getFlvStrategy = async (options) => {
19312
+ var _a, _b, _c, _d, _e, _f;
19313
+ let mseStrategy;
19314
+ let softStrategy;
19315
+ const enableLowLatency = ((_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.enableLowLatency) && sniffer$1.device === "pc";
19316
+ const enableFrameChasing = ((_c = (_b = options == null ? void 0 : options.flv) == null ? void 0 : _b.lowLatency) == null ? void 0 : _c.enableFrameChasing) ?? true;
19317
+ const abrPts = ((_e = (_d = options == null ? void 0 : options.flv) == null ? void 0 : _d.lowLatency) == null ? void 0 : _e.abrPts) ?? "-800";
19318
+ const codec = await getCodec(options);
19319
+ const isSoftDecode$1 = await isSoftDecode(options, codec);
19320
+ if (isSoftDecode$1) {
19321
+ softStrategy = codec === Codec.H265 ? createSoftDecodeH265Strategy() : createSoftDecodeH264Strategy();
19322
+ mseStrategy = createFlvMseStrategy(options);
19323
+ }
19324
+ if (codec === "unknown" ? isFLVSupported$1(Codec.H264) : isFLVSupported$1(codec)) {
19325
+ mseStrategy = enableMMS() ? createFlvMssStrategy(options) : createFlvMseStrategy(options);
19326
+ }
19327
+ if (!mseStrategy && !softStrategy) {
19328
+ return {};
19329
+ }
19330
+ const [mseModule, softModule] = await Promise.all([
19331
+ (mseStrategy == null ? void 0 : mseStrategy.module) && load(mseStrategy.module).catch(() => void 0),
19332
+ (softStrategy == null ? void 0 : softStrategy.module) && load(softStrategy.module).catch(() => void 0)
19333
+ ]);
19334
+ (softModule == null ? void 0 : softModule.XGVideoPlugin) && ((_f = softStrategy == null ? void 0 : softStrategy.afterLoad) == null ? void 0 : _f.call(softStrategy, softModule == null ? void 0 : softModule.XGVideoPlugin));
19335
+ const combineOptions$1 = combineOptions([mseStrategy, softStrategy]);
19336
+ const plugins = [];
19337
+ if (enableLowLatency) {
19338
+ combineOptions$1.url = appendSearchParams(options.url, { abr_pts: abrPts });
19339
+ }
19340
+ if (mseModule) {
19341
+ plugins.push(mseModule.FlvPlugin);
19342
+ if (enableLowLatency && enableFrameChasing) {
19343
+ plugins.push(mseModule.Adaptive);
19344
+ }
19345
+ }
19346
+ return {
19347
+ options: combineOptions$1,
19348
+ plugins
19349
+ };
19350
+ };
19305
19351
  const getTypeStrategy = async (options, player) => {
19306
19352
  const type = options.url ? util.getStreamType(options.url) : "";
19307
19353
  if (!type || type === "unknown") {
@@ -22065,7 +22111,7 @@ var __publicField = (obj, key, value) => {
22065
22111
  }
22066
22112
  static get defaultConfig() {
22067
22113
  return {
22068
- appId: "",
22114
+ appId: 654925,
22069
22115
  enable: true,
22070
22116
  showUserIdInErrorPanel: true
22071
22117
  };
@@ -22075,10 +22121,6 @@ var __publicField = (obj, key, value) => {
22075
22121
  if (!this.config.enable) {
22076
22122
  return;
22077
22123
  }
22078
- if (!this.config.appId) {
22079
- console.info("not found appId, please generate an appId");
22080
- return;
22081
- }
22082
22124
  this._userId = ((_a = this.config) == null ? void 0 : _a.userId) || getUserId();
22083
22125
  this._deviceId = ((_b = this.config) == null ? void 0 : _b.deviceId) || getDeviceID();
22084
22126
  this.open();
@@ -22121,16 +22163,17 @@ var __publicField = (obj, key, value) => {
22121
22163
  this._liveLogger = new LoggerControl({
22122
22164
  Tea: q,
22123
22165
  player: this.player,
22124
- aid: this.config.appId,
22166
+ aid: this.config.appId || 654925,
22125
22167
  project_key: this.config.appId,
22126
22168
  app_name: this.config.appName || this.config.appId,
22127
22169
  user_id: this._userId,
22128
22170
  device_id: this._deviceId,
22171
+ error_report_stop: true,
22129
22172
  ext: {
22130
- veplayer_version: "2.5.0",
22131
- flv_version: "3.0.21-rc.2",
22132
- hls_version: "3.0.21-rc.2",
22133
- rts_version: "0.2.1-alpha.12"
22173
+ veplayer_version: "2.5.1-rc.1",
22174
+ flv_version: "3.0.21-rc.5",
22175
+ hls_version: "3.0.21-rc.5",
22176
+ rts_version: "0.2.1-alpha.14"
22134
22177
  }
22135
22178
  });
22136
22179
  }
@@ -22362,6 +22405,7 @@ var __publicField = (obj, key, value) => {
22362
22405
  const EN = {
22363
22406
  ...EN$1,
22364
22407
  INVALID_PARAMETER: "The imported parameter is empty, please pass in necessary parameters such as the stream address",
22408
+ INVALID_LOGGER: "Log options not configured correctly. Please refer to this document https://docs.byteplus.com/en/docs/byteplus-media-live/docs-feature-implementation#uploading-logs to configure the logs.",
22365
22409
  // info-panel
22366
22410
  FORMAT: "format",
22367
22411
  FPS: "fps",
@@ -22379,6 +22423,7 @@ var __publicField = (obj, key, value) => {
22379
22423
  const ZH_CN = {
22380
22424
  ...ZH_CN$1,
22381
22425
  INVALID_PARAMETER: "入参为空,请传入流地址等必要参数",
22426
+ INVALID_LOGGER: "未正确配置质量日志参数, 请参考 https://www.volcengine.com/docs/6469/138655#日志上报 配置",
22382
22427
  // info-panel
22383
22428
  FORMAT: "格式",
22384
22429
  FPS: "帧率",
@@ -22649,15 +22694,18 @@ var __publicField = (obj, key, value) => {
22649
22694
  }
22650
22695
  }
22651
22696
  async function createLivePlayer(options) {
22652
- var _a, _b;
22697
+ var _a, _b, _c, _d;
22653
22698
  let player = void 0;
22654
- if (!options || !options.url && !options.playlist) {
22655
- throw create(ErrorCode.INVALID_PARAMETER, new VeI18n());
22656
- }
22657
22699
  const i18n = new VeI18n({
22658
22700
  lang: options == null ? void 0 : options.lang,
22659
22701
  i18n: options == null ? void 0 : options.i18n
22660
22702
  });
22703
+ if (!options || !options.url && !options.playlist) {
22704
+ throw create(ErrorCode.INVALID_PARAMETER, i18n);
22705
+ }
22706
+ if (!((_a = options.logger) == null ? void 0 : _a.appId) && ((_b = options == null ? void 0 : options.logger) == null ? void 0 : _b.enable) !== false) {
22707
+ console.warn(create(ErrorCode.INVALID_LOGGER, i18n).message);
22708
+ }
22661
22709
  const finalOptions = {
22662
22710
  ...options,
22663
22711
  plugins: [...LIVE_DEFAULT_PLUGINS, ...options.plugins ?? []]
@@ -22710,7 +22758,7 @@ var __publicField = (obj, key, value) => {
22710
22758
  VePlayerLive
22711
22759
  );
22712
22760
  if (player) {
22713
- const RTMDegrade = (_b = (_a = player == null ? void 0 : player._player) == null ? void 0 : _a.config) == null ? void 0 : _b._RTMdegrade;
22761
+ const RTMDegrade = (_d = (_c = player == null ? void 0 : player._player) == null ? void 0 : _c.config) == null ? void 0 : _d._RTMdegrade;
22714
22762
  if (RTMDegrade) {
22715
22763
  player.emit("degrade", {
22716
22764
  originRtmUrl: RTMDegrade._originRtmUrl,
@@ -22724,7 +22772,7 @@ var __publicField = (obj, key, value) => {
22724
22772
  return player;
22725
22773
  }
22726
22774
  function isFLVSupported() {
22727
- return isMseSupported$1() || isMMSSupported$1();
22775
+ return isMseSupported$2() || isMMSSupported$2();
22728
22776
  }
22729
22777
  var live = /* @__PURE__ */ Object.freeze({
22730
22778
  __proto__: null,