@volcengine/veplayer 2.5.0 → 2.5.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.2";
1460
+ var version = "3.0.21-rc.5";
1461
1461
  var ERROR_TYPE_MAP = {
1462
1462
  1: "media",
1463
1463
  2: "media",
@@ -1913,7 +1913,7 @@ var MediaProxy = /* @__PURE__ */ function(_EventEmitter) {
1913
1913
  var _e = this.media.error || error2;
1914
1914
  var type = _e.code ? ERROR_TYPE_MAP[_e.code] : "other";
1915
1915
  var message = _e.message;
1916
- if (!this.media.currentSrc) {
1916
+ if (!(this.media.currentSrc || this.media.srcObject)) {
1917
1917
  message = "empty_src";
1918
1918
  _e = {
1919
1919
  code: 6,
@@ -4127,6 +4127,10 @@ var Controls = /* @__PURE__ */ function(_Plugin) {
4127
4127
  this.unbind("mouseenter", this.onMouseEnter);
4128
4128
  this.unbind("mouseleave", this.onMouseLeave);
4129
4129
  }
4130
+ this.left = null;
4131
+ this.center = null;
4132
+ this.right = null;
4133
+ this.innerRoot = null;
4130
4134
  }
4131
4135
  }, {
4132
4136
  key: "render",
@@ -12840,7 +12844,7 @@ async function load(name, src2) {
12840
12844
  });
12841
12845
  }
12842
12846
  }
12843
- const appendSearchParams = (url, searchParams) => {
12847
+ const appendSearchParams$1 = (url, searchParams) => {
12844
12848
  var _a, _b;
12845
12849
  const urlObject = getUrlObject(url);
12846
12850
  if (!url || !urlObject) {
@@ -12875,6 +12879,13 @@ const getUrlObject = (url) => {
12875
12879
  return;
12876
12880
  }
12877
12881
  };
12882
+ const H264_MIME = 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';
12883
+ const H265_MIME = [
12884
+ 'video/mp4;codecs="hev1.1.6.L120.90"',
12885
+ 'video/mp4;codecs="hev1.2.4.L120.90"',
12886
+ 'video/mp4;codecs="hev1.3.E.L120.90"',
12887
+ 'video/mp4;codecs="hev1.4.10.L120.90"'
12888
+ ];
12878
12889
  function isType(suffix) {
12879
12890
  return function(url) {
12880
12891
  return url == null ? void 0 : url.split("?")[0].toLowerCase().includes(suffix);
@@ -12903,26 +12914,40 @@ function getStreamType(url) {
12903
12914
  }
12904
12915
  return "unknown";
12905
12916
  }
12906
- function isMseSupported$1(codec = Codec.H264) {
12917
+ function isMseSupported$2(codec = Codec.H264) {
12907
12918
  if (codec === Codec.H265) {
12908
12919
  return sniffer$1.isHevcSupported();
12909
12920
  }
12910
- return sniffer$1.isMSESupport();
12921
+ if (codec === Codec.H264) {
12922
+ return sniffer$1.isMSESupport();
12923
+ }
12924
+ return sniffer$1.isMSESupport(codec);
12911
12925
  }
12912
12926
  async function isSoftDecodeSupported$1() {
12913
12927
  const { XGVideoPlugin } = await load(DynamicModule.PluginXgvideo);
12914
12928
  return XGVideoPlugin == null ? void 0 : XGVideoPlugin.isSupported();
12915
12929
  }
12916
- function isMMSSupported$1() {
12917
- return typeof ManagedMediaSource !== "undefined";
12930
+ function isMMSSupported$2(codec = Codec.H264) {
12931
+ if (typeof window.ManagedMediaSource === "undefined") {
12932
+ return false;
12933
+ }
12934
+ if (codec === Codec.H264) {
12935
+ return window.ManagedMediaSource.isTypeSupported(H264_MIME);
12936
+ }
12937
+ if (codec === Codec.H265) {
12938
+ return H265_MIME.some((mine) => {
12939
+ return window.ManagedMediaSource.isTypeSupported(mine);
12940
+ });
12941
+ }
12942
+ return window.ManagedMediaSource.isTypeSupported(codec);
12918
12943
  }
12919
12944
  const util = {
12920
12945
  ...util$1,
12921
12946
  getStreamType,
12922
- isMseSupported: isMseSupported$1,
12947
+ isMseSupported: isMseSupported$2,
12923
12948
  isSoftDecodeSupported: isSoftDecodeSupported$1,
12924
- isMMSSupported: isMMSSupported$1,
12925
- appendSearchParams,
12949
+ isMMSSupported: isMMSSupported$2,
12950
+ appendSearchParams: appendSearchParams$1,
12926
12951
  getUrlObject
12927
12952
  };
12928
12953
  var autoplay = "";
@@ -13843,7 +13868,7 @@ class VePlayerBase {
13843
13868
  * @brief Retrieve the player SDK version number.
13844
13869
  */
13845
13870
  get playerVersion() {
13846
- return "2.5.0";
13871
+ return "2.5.1-rc.0";
13847
13872
  }
13848
13873
  /** {zh}
13849
13874
  * @brief 获取当前播放视频的清晰度唯一标识(definition)。
@@ -18964,48 +18989,6 @@ class Lite {
18964
18989
  return result;
18965
18990
  }
18966
18991
  }
18967
- const getFlvStrategy = async (options) => {
18968
- var _a, _b, _c, _d, _e, _f;
18969
- let mseStrategy;
18970
- let softStrategy;
18971
- const enableLowLatency = ((_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.enableLowLatency) && sniffer$1.device === "pc";
18972
- const enableFrameChasing = ((_c = (_b = options == null ? void 0 : options.flv) == null ? void 0 : _b.lowLatency) == null ? void 0 : _c.enableFrameChasing) ?? true;
18973
- const abrPts = ((_e = (_d = options == null ? void 0 : options.flv) == null ? void 0 : _d.lowLatency) == null ? void 0 : _e.abrPts) ?? "-800";
18974
- const codec = await getCodec(options);
18975
- const isSoftDecode$1 = await isSoftDecode(options, codec);
18976
- if (isSoftDecode$1) {
18977
- softStrategy = codec === Codec.H265 ? createSoftDecodeH265Strategy() : createSoftDecodeH264Strategy();
18978
- mseStrategy = createFlvMseStrategy(options);
18979
- }
18980
- if (codec === "unknown" ? isMseSupported$1(Codec.H264) : isMseSupported$1(codec)) {
18981
- mseStrategy = createFlvMseStrategy(options);
18982
- } else if (isMMSSupported$1()) {
18983
- mseStrategy = createFlvMssStrategy(options);
18984
- }
18985
- if (!mseStrategy && !softStrategy) {
18986
- return {};
18987
- }
18988
- const [mseModule, softModule] = await Promise.all([
18989
- (mseStrategy == null ? void 0 : mseStrategy.module) && load(mseStrategy.module).catch(() => void 0),
18990
- (softStrategy == null ? void 0 : softStrategy.module) && load(softStrategy.module).catch(() => void 0)
18991
- ]);
18992
- (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));
18993
- const combineOptions$1 = combineOptions([mseStrategy, softStrategy]);
18994
- const plugins = [];
18995
- if (enableLowLatency) {
18996
- combineOptions$1.url = appendSearchParams(options.url, { abr_pts: abrPts });
18997
- }
18998
- if (mseModule) {
18999
- plugins.push(mseModule.FlvPlugin);
19000
- if (enableLowLatency && enableFrameChasing) {
19001
- plugins.push(mseModule.Adaptive);
19002
- }
19003
- }
19004
- return {
19005
- options: combineOptions$1,
19006
- plugins
19007
- };
19008
- };
19009
18992
  const getHlsStrategy = async (options) => {
19010
18993
  var _a, _b;
19011
18994
  let mseStrategy;
@@ -19016,7 +18999,7 @@ const getHlsStrategy = async (options) => {
19016
18999
  softStrategy = codec === Codec.H265 ? createSoftDecodeH265Strategy() : createSoftDecodeH264Strategy();
19017
19000
  mseStrategy = createHlsMseStrategy(options);
19018
19001
  }
19019
- 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))) {
19002
+ 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))) {
19020
19003
  mseStrategy = createHlsMseStrategy(options);
19021
19004
  }
19022
19005
  if (!mseStrategy && !softStrategy) {
@@ -19163,6 +19146,7 @@ function combineOptions(strategyList) {
19163
19146
  const { VeError: VeError2 } = error$1;
19164
19147
  var LiveErrorCode = /* @__PURE__ */ ((LiveErrorCode2) => {
19165
19148
  LiveErrorCode2[LiveErrorCode2["INVALID_PARAMETER"] = 210] = "INVALID_PARAMETER";
19149
+ LiveErrorCode2[LiveErrorCode2["INVALID_LOGGER"] = 220] = "INVALID_LOGGER";
19166
19150
  return LiveErrorCode2;
19167
19151
  })(LiveErrorCode || {});
19168
19152
  const ErrorCode = {
@@ -19177,10 +19161,23 @@ const ERRORS = {
19177
19161
  ]: {
19178
19162
  messageTextKey: "INVALID_PARAMETER",
19179
19163
  level: Level.Fatal
19164
+ },
19165
+ [
19166
+ 220
19167
+ /* INVALID_LOGGER */
19168
+ ]: {
19169
+ messageTextKey: "INVALID_LOGGER",
19170
+ level: Level.Error
19180
19171
  }
19181
19172
  };
19182
19173
  function create(errorCode, i18n) {
19183
- return new VeError2(ERRORS[errorCode], i18n);
19174
+ return new VeError2(
19175
+ {
19176
+ errorCode,
19177
+ ...ERRORS[errorCode]
19178
+ },
19179
+ i18n
19180
+ );
19184
19181
  }
19185
19182
  async function isRTMSupported() {
19186
19183
  const { RtmPlugin } = await load(DynamicModule.PluginRtm);
@@ -19298,6 +19295,55 @@ function isMseSupportedWithDrm({
19298
19295
  }
19299
19296
  return true;
19300
19297
  }
19298
+ const { isMMSSupported: isMMSSupported$1, isMseSupported: isMseSupported$1 } = util;
19299
+ function enableMMS() {
19300
+ return sniffer$1.os.isIos;
19301
+ }
19302
+ function isFLVSupported(codec = Codec.H264) {
19303
+ const isMediaSourceSupported = enableMMS() ? isMMSSupported$1 : isMseSupported$1;
19304
+ return isMediaSourceSupported(codec);
19305
+ }
19306
+ const { appendSearchParams } = util;
19307
+ const getFlvStrategy = async (options) => {
19308
+ var _a, _b, _c, _d, _e, _f;
19309
+ let mseStrategy;
19310
+ let softStrategy;
19311
+ const enableLowLatency = ((_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.enableLowLatency) && sniffer$1.device === "pc";
19312
+ const enableFrameChasing = ((_c = (_b = options == null ? void 0 : options.flv) == null ? void 0 : _b.lowLatency) == null ? void 0 : _c.enableFrameChasing) ?? true;
19313
+ const abrPts = ((_e = (_d = options == null ? void 0 : options.flv) == null ? void 0 : _d.lowLatency) == null ? void 0 : _e.abrPts) ?? "-800";
19314
+ const codec = await getCodec(options);
19315
+ const isSoftDecode$1 = await isSoftDecode(options, codec);
19316
+ if (isSoftDecode$1) {
19317
+ softStrategy = codec === Codec.H265 ? createSoftDecodeH265Strategy() : createSoftDecodeH264Strategy();
19318
+ mseStrategy = createFlvMseStrategy(options);
19319
+ }
19320
+ if (codec === "unknown" ? isFLVSupported(Codec.H264) : isFLVSupported(codec)) {
19321
+ mseStrategy = enableMMS() ? createFlvMssStrategy(options) : createFlvMseStrategy(options);
19322
+ }
19323
+ if (!mseStrategy && !softStrategy) {
19324
+ return {};
19325
+ }
19326
+ const [mseModule, softModule] = await Promise.all([
19327
+ (mseStrategy == null ? void 0 : mseStrategy.module) && load(mseStrategy.module).catch(() => void 0),
19328
+ (softStrategy == null ? void 0 : softStrategy.module) && load(softStrategy.module).catch(() => void 0)
19329
+ ]);
19330
+ (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));
19331
+ const combineOptions$1 = combineOptions([mseStrategy, softStrategy]);
19332
+ const plugins = [];
19333
+ if (enableLowLatency) {
19334
+ combineOptions$1.url = appendSearchParams(options.url, { abr_pts: abrPts });
19335
+ }
19336
+ if (mseModule) {
19337
+ plugins.push(mseModule.FlvPlugin);
19338
+ if (enableLowLatency && enableFrameChasing) {
19339
+ plugins.push(mseModule.Adaptive);
19340
+ }
19341
+ }
19342
+ return {
19343
+ options: combineOptions$1,
19344
+ plugins
19345
+ };
19346
+ };
19301
19347
  const getTypeStrategy = async (options, player) => {
19302
19348
  const type = options.url ? util.getStreamType(options.url) : "";
19303
19349
  if (!type || type === "unknown") {
@@ -22061,7 +22107,7 @@ class Logger extends Plugin {
22061
22107
  }
22062
22108
  static get defaultConfig() {
22063
22109
  return {
22064
- appId: "",
22110
+ appId: 654925,
22065
22111
  enable: true,
22066
22112
  showUserIdInErrorPanel: true
22067
22113
  };
@@ -22071,10 +22117,6 @@ class Logger extends Plugin {
22071
22117
  if (!this.config.enable) {
22072
22118
  return;
22073
22119
  }
22074
- if (!this.config.appId) {
22075
- console.info("not found appId, please generate an appId");
22076
- return;
22077
- }
22078
22120
  this._userId = ((_a = this.config) == null ? void 0 : _a.userId) || getUserId2();
22079
22121
  this._deviceId = ((_b = this.config) == null ? void 0 : _b.deviceId) || getDeviceID2();
22080
22122
  this.open();
@@ -22117,16 +22159,17 @@ class Logger extends Plugin {
22117
22159
  this._liveLogger = new LoggerControl({
22118
22160
  Tea: q,
22119
22161
  player: this.player,
22120
- aid: this.config.appId,
22162
+ aid: this.config.appId || 654925,
22121
22163
  project_key: this.config.appId,
22122
22164
  app_name: this.config.appName || this.config.appId,
22123
22165
  user_id: this._userId,
22124
22166
  device_id: this._deviceId,
22167
+ error_report_stop: true,
22125
22168
  ext: {
22126
- veplayer_version: "2.5.0",
22127
- flv_version: "3.0.21-rc.2",
22128
- hls_version: "3.0.21-rc.2",
22129
- rts_version: "0.2.1-alpha.12"
22169
+ veplayer_version: "2.5.1-rc.0",
22170
+ flv_version: "3.0.21-rc.5",
22171
+ hls_version: "3.0.21-rc.5",
22172
+ rts_version: "0.2.1-alpha.14"
22130
22173
  }
22131
22174
  });
22132
22175
  }
@@ -22358,6 +22401,7 @@ class InfoPanel extends Plugin {
22358
22401
  const EN = {
22359
22402
  ...EN$1,
22360
22403
  INVALID_PARAMETER: "The imported parameter is empty, please pass in necessary parameters such as the stream address",
22404
+ 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.",
22361
22405
  // info-panel
22362
22406
  FORMAT: "format",
22363
22407
  FPS: "fps",
@@ -22375,6 +22419,7 @@ const EN = {
22375
22419
  const ZH_CN = {
22376
22420
  ...ZH_CN$1,
22377
22421
  INVALID_PARAMETER: "入参为空,请传入流地址等必要参数",
22422
+ INVALID_LOGGER: "未正确配置质量日志参数, 请参考 https://www.volcengine.com/docs/6469/138655#日志上报 配置",
22378
22423
  // info-panel
22379
22424
  FORMAT: "格式",
22380
22425
  FPS: "帧率",
@@ -22645,15 +22690,18 @@ class VePlayerLive extends VePlayerBase {
22645
22690
  }
22646
22691
  }
22647
22692
  async function createLivePlayer(options) {
22648
- var _a, _b;
22693
+ var _a, _b, _c, _d;
22649
22694
  let player = void 0;
22650
- if (!options || !options.url && !options.playlist) {
22651
- throw create(ErrorCode.INVALID_PARAMETER, new VeI18n());
22652
- }
22653
22695
  const i18n = new VeI18n({
22654
22696
  lang: options == null ? void 0 : options.lang,
22655
22697
  i18n: options == null ? void 0 : options.i18n
22656
22698
  });
22699
+ if (!options || !options.url && !options.playlist) {
22700
+ throw create(ErrorCode.INVALID_PARAMETER, i18n);
22701
+ }
22702
+ if (!((_a = options.logger) == null ? void 0 : _a.appId) && ((_b = options == null ? void 0 : options.logger) == null ? void 0 : _b.enable) !== false) {
22703
+ console.warn(create(ErrorCode.INVALID_LOGGER, i18n).message);
22704
+ }
22657
22705
  const finalOptions = {
22658
22706
  ...options,
22659
22707
  plugins: [...LIVE_DEFAULT_PLUGINS, ...options.plugins ?? []]
@@ -22706,7 +22754,7 @@ async function createLivePlayer(options) {
22706
22754
  VePlayerLive
22707
22755
  );
22708
22756
  if (player) {
22709
- const RTMDegrade = (_b = (_a = player == null ? void 0 : player._player) == null ? void 0 : _a.config) == null ? void 0 : _b._RTMdegrade;
22757
+ const RTMDegrade = (_d = (_c = player == null ? void 0 : player._player) == null ? void 0 : _c.config) == null ? void 0 : _d._RTMdegrade;
22710
22758
  if (RTMDegrade) {
22711
22759
  player.emit("degrade", {
22712
22760
  originRtmUrl: RTMDegrade._originRtmUrl,
@@ -22719,9 +22767,6 @@ async function createLivePlayer(options) {
22719
22767
  }
22720
22768
  return player;
22721
22769
  }
22722
- function isFLVSupported() {
22723
- return isMseSupported$1() || isMMSSupported$1();
22724
- }
22725
22770
  var live = /* @__PURE__ */ Object.freeze({
22726
22771
  __proto__: null,
22727
22772
  ErrorCode,