@volcengine/veplayer 2.5.0-rc.1 → 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.
@@ -8,6 +8,7 @@ const error = window["VePlayer"].error;
8
8
  const { VeError } = error;
9
9
  var LiveErrorCode = /* @__PURE__ */ ((LiveErrorCode2) => {
10
10
  LiveErrorCode2[LiveErrorCode2["INVALID_PARAMETER"] = 210] = "INVALID_PARAMETER";
11
+ LiveErrorCode2[LiveErrorCode2["INVALID_LOGGER"] = 220] = "INVALID_LOGGER";
11
12
  return LiveErrorCode2;
12
13
  })(LiveErrorCode || {});
13
14
  error.Level;
@@ -23,35 +24,48 @@ const ERRORS = {
23
24
  ]: {
24
25
  messageTextKey: "INVALID_PARAMETER",
25
26
  level: error.Level.Fatal
27
+ },
28
+ [
29
+ 220
30
+ /* INVALID_LOGGER */
31
+ ]: {
32
+ messageTextKey: "INVALID_LOGGER",
33
+ level: error.Level.Error
26
34
  }
27
35
  };
28
36
  function create(errorCode, i18n) {
29
- return new VeError(ERRORS[errorCode], i18n);
37
+ return new VeError(
38
+ {
39
+ errorCode,
40
+ ...ERRORS[errorCode]
41
+ },
42
+ i18n
43
+ );
30
44
  }
31
45
  const DynamicModule$4 = window["VePlayer"].DynamicModule;
32
- const load$4 = window["VePlayer"].load;
46
+ const load$5 = window["VePlayer"].load;
33
47
  async function isRTMSupported() {
34
- const { RtmPlugin } = await load$4(DynamicModule$4.PluginRtm);
48
+ const { RtmPlugin } = await load$5(DynamicModule$4.PluginRtm);
35
49
  return RtmPlugin.isSupported();
36
50
  }
37
51
  async function isRTMSupportCodec(codec = RTMCodec.H264) {
38
- const { RtmPlugin } = await load$4(DynamicModule$4.PluginRtm);
52
+ const { RtmPlugin } = await load$5(DynamicModule$4.PluginRtm);
39
53
  if (codec === RTMCodec.H264)
40
54
  return RtmPlugin.isSupportedH264();
41
55
  return false;
42
56
  }
43
- const strategy$1 = window["VePlayer"].strategy;
44
- const util$4 = window["VePlayer"].util;
57
+ const strategy$2 = window["VePlayer"].strategy;
58
+ const util$6 = window["VePlayer"].util;
45
59
  const DynamicModule$3 = window["VePlayer"].DynamicModule;
46
- const load$3 = window["VePlayer"].load;
47
- const Codec$1 = window["VePlayer"].Codec;
48
- const Sniffer$3 = window["VePlayer"].Sniffer;
60
+ const load$4 = window["VePlayer"].load;
61
+ const Codec$3 = window["VePlayer"].Codec;
62
+ const Sniffer$5 = window["VePlayer"].Sniffer;
49
63
  const rtmStrategy = {
50
64
  options: {},
51
65
  module: DynamicModule$3.PluginRtm
52
66
  };
53
67
  const generateFallbackUrl = (url) => {
54
- if (Sniffer$3.device === "pc") {
68
+ if (Sniffer$5.device === "pc") {
55
69
  return url.replace(".sdp", ".flv");
56
70
  } else {
57
71
  return url.replace(".sdp", ".m3u8");
@@ -68,17 +82,17 @@ const getRtmStrategy = async (options, player) => {
68
82
  ...ret
69
83
  } = options.rtm || {};
70
84
  const actualFallbackUrl = !enableFallback ? "" : !fallbackUrl && url ? generateFallbackUrl(url) : fallbackUrl;
71
- const backupType = actualFallbackUrl && util$4.getStreamType(actualFallbackUrl);
72
- if (backupType === "flv" && util$4.isMseSupported(Codec$1.H264)) {
73
- backupStrategy = strategy$1.createFlvMseStrategy(options);
74
- } else if (backupType === "hls" && (Sniffer$3.device !== "mobile" || ((_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.enableMSE)) && util$4.isMseSupported(Codec$1.H264)) {
75
- backupStrategy = strategy$1.createHlsMseStrategy(options);
85
+ const backupType = actualFallbackUrl && util$6.getStreamType(actualFallbackUrl);
86
+ if (backupType === "flv" && util$6.isMseSupported(Codec$3.H264)) {
87
+ backupStrategy = strategy$2.createFlvMseStrategy(options);
88
+ } else if (backupType === "hls" && (Sniffer$5.device !== "mobile" || ((_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.enableMSE)) && util$6.isMseSupported(Codec$3.H264)) {
89
+ backupStrategy = strategy$2.createHlsMseStrategy(options);
76
90
  }
77
91
  const [rtmCdn, backupCdn] = await Promise.all([
78
- load$3(rtmStrategy.module).then((module) => {
92
+ load$4(rtmStrategy.module).then((module) => {
79
93
  return module.RtmPlugin;
80
94
  }).catch(() => void 0),
81
- backupStrategy && load$3(backupStrategy.module).then((module) => {
95
+ backupStrategy && load$4(backupStrategy.module).then((module) => {
82
96
  if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule$3.PluginFlv) {
83
97
  return module.FlvPlugin;
84
98
  } else if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule$3.PluginHls) {
@@ -117,7 +131,7 @@ const getRtmStrategy = async (options, player) => {
117
131
  return {
118
132
  options: {
119
133
  ...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
120
- url: enableRTMAutoTranscode ? util$4.appendSearchParams(url, { enableRTMAutoTranscode: "true" }) : void 0,
134
+ url: enableRTMAutoTranscode ? util$6.appendSearchParams(url, { enableRTMAutoTranscode: "true" }) : void 0,
121
135
  _RTMdegrade: void 0,
122
136
  rts: {
123
137
  retryCount: 0,
@@ -129,13 +143,13 @@ const getRtmStrategy = async (options, player) => {
129
143
  plugins: rtmCdn ? [rtmCdn] : []
130
144
  };
131
145
  };
132
- const Sniffer$2 = window["VePlayer"].Sniffer;
146
+ const Sniffer$4 = window["VePlayer"].Sniffer;
133
147
  var DrmType = /* @__PURE__ */ ((DrmType2) => {
134
148
  DrmType2["Fairplay"] = "fairplay";
135
149
  return DrmType2;
136
150
  })(DrmType || {});
137
151
  function getDrmType(drm) {
138
- if ((drm == null ? void 0 : drm.fairplay) && (Sniffer$2.browser === "safari" || Sniffer$2.os.isIos)) {
152
+ if ((drm == null ? void 0 : drm.fairplay) && (Sniffer$4.browser === "safari" || Sniffer$4.os.isIos)) {
139
153
  return "fairplay";
140
154
  }
141
155
  return;
@@ -153,6 +167,63 @@ function isMseSupportedWithDrm({
153
167
  }
154
168
  return true;
155
169
  }
170
+ const Sniffer$3 = window["VePlayer"].Sniffer;
171
+ const Codec$2 = window["VePlayer"].Codec;
172
+ const util$5 = window["VePlayer"].util;
173
+ const { isMMSSupported: isMMSSupported$1, isMseSupported: isMseSupported$1 } = util$5;
174
+ function enableMMS() {
175
+ return Sniffer$3.os.isIos;
176
+ }
177
+ function isFLVSupported(codec = Codec$2.H264) {
178
+ const isMediaSourceSupported = enableMMS() ? isMMSSupported$1 : isMseSupported$1;
179
+ return isMediaSourceSupported(codec);
180
+ }
181
+ const strategy$1 = window["VePlayer"].strategy;
182
+ const load$3 = window["VePlayer"].load;
183
+ const Sniffer$2 = window["VePlayer"].Sniffer;
184
+ const Codec$1 = window["VePlayer"].Codec;
185
+ const util$4 = window["VePlayer"].util;
186
+ const { appendSearchParams } = util$4;
187
+ const getFlvStrategy = async (options) => {
188
+ var _a, _b, _c, _d, _e, _f;
189
+ let mseStrategy;
190
+ let softStrategy;
191
+ const enableLowLatency = ((_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.enableLowLatency) && Sniffer$2.device === "pc";
192
+ const enableFrameChasing = ((_c = (_b = options == null ? void 0 : options.flv) == null ? void 0 : _b.lowLatency) == null ? void 0 : _c.enableFrameChasing) ?? true;
193
+ const abrPts = ((_e = (_d = options == null ? void 0 : options.flv) == null ? void 0 : _d.lowLatency) == null ? void 0 : _e.abrPts) ?? "-800";
194
+ const codec = await strategy$1.getCodec(options);
195
+ const isSoftDecode = await strategy$1.isSoftDecode(options, codec);
196
+ if (isSoftDecode) {
197
+ softStrategy = codec === Codec$1.H265 ? strategy$1.createSoftDecodeH265Strategy() : strategy$1.createSoftDecodeH264Strategy();
198
+ mseStrategy = strategy$1.createFlvMseStrategy(options);
199
+ }
200
+ if (codec === "unknown" ? isFLVSupported(Codec$1.H264) : isFLVSupported(codec)) {
201
+ mseStrategy = enableMMS() ? strategy$1.createFlvMssStrategy(options) : strategy$1.createFlvMseStrategy(options);
202
+ }
203
+ if (!mseStrategy && !softStrategy) {
204
+ return {};
205
+ }
206
+ const [mseModule, softModule] = await Promise.all([
207
+ (mseStrategy == null ? void 0 : mseStrategy.module) && load$3(mseStrategy.module).catch(() => void 0),
208
+ (softStrategy == null ? void 0 : softStrategy.module) && load$3(softStrategy.module).catch(() => void 0)
209
+ ]);
210
+ (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));
211
+ const combineOptions = strategy$1.combineOptions([mseStrategy, softStrategy]);
212
+ const plugins = [];
213
+ if (enableLowLatency) {
214
+ combineOptions.url = appendSearchParams(options.url, { abr_pts: abrPts });
215
+ }
216
+ if (mseModule) {
217
+ plugins.push(mseModule.FlvPlugin);
218
+ if (enableLowLatency && enableFrameChasing) {
219
+ plugins.push(mseModule.Adaptive);
220
+ }
221
+ }
222
+ return {
223
+ options: combineOptions,
224
+ plugins
225
+ };
226
+ };
156
227
  const util$3 = window["VePlayer"].util;
157
228
  const strategy = window["VePlayer"].strategy;
158
229
  const getTypeStrategy = async (options, player) => {
@@ -164,7 +235,7 @@ const getTypeStrategy = async (options, player) => {
164
235
  return await getRtmStrategy(options, player);
165
236
  }
166
237
  if (type === "flv") {
167
- return await strategy.getFlvStrategy(options);
238
+ return await getFlvStrategy(options);
168
239
  }
169
240
  if (type === "hls") {
170
241
  if (!isMseSupportedWithDrm({ drm: options.drm, streamType: type })) {
@@ -2928,7 +2999,7 @@ class Logger extends Plugin$2 {
2928
2999
  }
2929
3000
  static get defaultConfig() {
2930
3001
  return {
2931
- appId: "",
3002
+ appId: 654925,
2932
3003
  enable: true,
2933
3004
  showUserIdInErrorPanel: true
2934
3005
  };
@@ -2938,10 +3009,6 @@ class Logger extends Plugin$2 {
2938
3009
  if (!this.config.enable) {
2939
3010
  return;
2940
3011
  }
2941
- if (!this.config.appId) {
2942
- console.info("not found appId, please generate an appId");
2943
- return;
2944
- }
2945
3012
  this._userId = ((_a = this.config) == null ? void 0 : _a.userId) || getUserId2();
2946
3013
  this._deviceId = ((_b = this.config) == null ? void 0 : _b.deviceId) || getDeviceID2();
2947
3014
  this.open();
@@ -2984,16 +3051,17 @@ class Logger extends Plugin$2 {
2984
3051
  this._liveLogger = new LoggerControl({
2985
3052
  Tea: q,
2986
3053
  player: this.player,
2987
- aid: this.config.appId,
3054
+ aid: this.config.appId || 654925,
2988
3055
  project_key: this.config.appId,
2989
3056
  app_name: this.config.appName || this.config.appId,
2990
3057
  user_id: this._userId,
2991
3058
  device_id: this._deviceId,
3059
+ error_report_stop: true,
2992
3060
  ext: {
2993
3061
  veplayer_version: "2.3.1-rc.1",
2994
- flv_version: "3.0.19-rc.0",
2995
- hls_version: "3.0.20-alpha.2",
2996
- rts_version: "0.2.1-alpha.0"
3062
+ flv_version: "3.0.21-rc.5",
3063
+ hls_version: "3.0.21-rc.5",
3064
+ rts_version: "0.2.1-alpha.14"
2997
3065
  }
2998
3066
  });
2999
3067
  }
@@ -3229,6 +3297,7 @@ const BaseEN = window["VePlayer"].EN;
3229
3297
  const EN$1 = {
3230
3298
  ...BaseEN,
3231
3299
  INVALID_PARAMETER: "The imported parameter is empty, please pass in necessary parameters such as the stream address",
3300
+ 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.",
3232
3301
  // info-panel
3233
3302
  FORMAT: "format",
3234
3303
  FPS: "fps",
@@ -3247,6 +3316,7 @@ const BaseZH_CN = window["VePlayer"].ZH_CN;
3247
3316
  const ZH_CN$1 = {
3248
3317
  ...BaseZH_CN,
3249
3318
  INVALID_PARAMETER: "入参为空,请传入流地址等必要参数",
3319
+ INVALID_LOGGER: "未正确配置质量日志参数, 请参考 https://www.volcengine.com/docs/6469/138655#日志上报 配置",
3250
3320
  // info-panel
3251
3321
  FORMAT: "格式",
3252
3322
  FPS: "帧率",
@@ -3361,7 +3431,9 @@ VeI18n.extend([
3361
3431
  }
3362
3432
  ]);
3363
3433
  const LIVE_DEFAULT_OPTIONS = {
3364
- autoplay: { muted: true }
3434
+ autoplay: {
3435
+ muted: true
3436
+ }
3365
3437
  };
3366
3438
  const LIVE_DEFAULT_PLUGINS = [...DEFAULT_PLUGINS, Refresh, Logger, InfoPanel];
3367
3439
  var RTMCodec = /* @__PURE__ */ ((RTMCodec2) => {
@@ -3381,7 +3453,10 @@ class VePlayerLive extends VePlayerBase {
3381
3453
  super(options);
3382
3454
  }
3383
3455
  /** {zh}
3384
- * @brief 获取已经播放的时间
3456
+ * @brief 获取已经播放的时长,不包含暂停和等待时间,单位为秒。
3457
+ */
3458
+ /** {en}
3459
+ * @brief Obtain the duration that has been played, excluding pause and waiting time, with the unit of seconds.
3385
3460
  */
3386
3461
  get playTime() {
3387
3462
  var _a, _b, _c, _d;
@@ -3440,7 +3515,10 @@ class VePlayerLive extends VePlayerBase {
3440
3515
  (_a = this._player.plugins) == null ? void 0 : _a.infopanel.close();
3441
3516
  }
3442
3517
  /** {zh}
3443
- * @brief 打开 Abr
3518
+ * @brief 打开码率自适应(ABR)切换功能。
3519
+ */
3520
+ /** {en}
3521
+ * @brief Enable the Adaptive Bitrate Streaming (ABR) switching feature.
3444
3522
  */
3445
3523
  openAbr() {
3446
3524
  var _a, _b, _c, _d;
@@ -3454,7 +3532,10 @@ class VePlayerLive extends VePlayerBase {
3454
3532
  }
3455
3533
  }
3456
3534
  /** {zh}
3457
- * @brief 关闭 Abr
3535
+ * @brief 关闭码率自适应(ABR)切换功能。
3536
+ */
3537
+ /** {en}
3538
+ * @brief Disable the Adaptive Bitrate Streaming (ABR) switching feature.
3458
3539
  */
3459
3540
  closeAbr() {
3460
3541
  var _a, _b, _c, _d;
@@ -3468,18 +3549,25 @@ class VePlayerLive extends VePlayerBase {
3468
3549
  }
3469
3550
  }
3470
3551
  /** {zh}
3471
- * @brief 调用此方法更新 DRM 鉴权配置。
3472
- * @hidden
3552
+ * @brief 调用此方法更新 DRM 配置。
3553
+ */
3554
+ /** {en}
3555
+ * @brief Use this method to update DRM configuration.
3556
+ * @param config
3473
3557
  */
3474
3558
  updateDrmConfig(config) {
3475
3559
  var _a, _b, _c;
3476
3560
  (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.drm) == null ? void 0 : _c.updateDrmConfig(config);
3477
3561
  }
3478
3562
  /** {zh}
3479
- * @brief 切换 flv Abr
3480
- * @param options 切换 Abr 的配置。
3563
+ * @brief 修改 ABR 配置,包含修改是否开启 ABR 功能,和修改其他清晰度。
3564
+ * @param options ABR 的配置。
3481
3565
  * @returns
3482
3566
  */
3567
+ /** {en}
3568
+ * @brief Modify ABR configuration, including enabling or disabling the ABR feature and adjusting other resolutions.
3569
+ * @param options Configuration of ABR.
3570
+ */
3483
3571
  switchAbr(options) {
3484
3572
  var _a, _b;
3485
3573
  if (!((_a = this._player.plugins) == null ? void 0 : _a.abr)) {
@@ -3490,7 +3578,9 @@ class VePlayerLive extends VePlayerBase {
3490
3578
  if (!url) {
3491
3579
  return;
3492
3580
  }
3493
- this.switch(url, { seamless: true });
3581
+ this.switch(url, {
3582
+ seamless: true
3583
+ });
3494
3584
  this._player.plugins.abr.bitrate = options.bitrate;
3495
3585
  }
3496
3586
  if (typeof (options == null ? void 0 : options.enable) !== "undefined") {
@@ -3498,37 +3588,52 @@ class VePlayerLive extends VePlayerBase {
3498
3588
  }
3499
3589
  }
3500
3590
  /** {zh}
3501
- * @brief 获取 RTM 的网络相关信息
3591
+ * @brief 获取 RTM 拉流的网络评估信息。
3502
3592
  * @returns
3503
3593
  */
3594
+ /** {en}
3595
+ * @brief Obtain the network assessment information of RTM pull streaming.
3596
+ */
3504
3597
  getRTMNetWorkInfo() {
3505
3598
  var _a, _b, _c;
3506
3599
  return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getNetWorkInfo();
3507
3600
  }
3508
3601
  /** {zh}
3509
- * @brief 获取 RTM 播放信息
3602
+ * @brief 获取 RTM 拉流的播放信息。
3510
3603
  * @returns
3511
3604
  */
3605
+ /** {en}
3606
+ * @brief Obtain the playback information of RTM pull stream.
3607
+ */
3512
3608
  async getRTMStats() {
3513
3609
  var _a, _b, _c;
3514
3610
  return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getStatsSnapshoot();
3515
3611
  }
3516
3612
  /** {zh}
3517
- * @brief 获取 FLV 播放信息
3613
+ * @brief 获取 FLV 拉流的播放信息。
3518
3614
  * @returns
3519
3615
  */
3616
+ /** {en}
3617
+ * @brief Obtain the playback information of FLV pull streaming.
3618
+ */
3520
3619
  getFLVStats() {
3521
3620
  var _a, _b, _c;
3522
3621
  return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.flv) == null ? void 0 : _c.getStats();
3523
3622
  }
3524
3623
  }
3525
3624
  async function createLivePlayer(options) {
3526
- var _a, _b;
3625
+ var _a, _b, _c, _d;
3527
3626
  let player = void 0;
3627
+ const i18n = new VeI18n({
3628
+ lang: options == null ? void 0 : options.lang,
3629
+ i18n: options == null ? void 0 : options.i18n
3630
+ });
3528
3631
  if (!options || !options.url && !options.playlist) {
3529
- throw create(ErrorCode.INVALID_PARAMETER, new VeI18n());
3632
+ throw create(ErrorCode.INVALID_PARAMETER, i18n);
3633
+ }
3634
+ if (!((_a = options.logger) == null ? void 0 : _a.appId) && ((_b = options == null ? void 0 : options.logger) == null ? void 0 : _b.enable) !== false) {
3635
+ console.warn(create(ErrorCode.INVALID_LOGGER, i18n).message);
3530
3636
  }
3531
- const i18n = new VeI18n({ lang: options == null ? void 0 : options.lang, i18n: options == null ? void 0 : options.i18n });
3532
3637
  const finalOptions = {
3533
3638
  ...options,
3534
3639
  plugins: [...LIVE_DEFAULT_PLUGINS, ...options.plugins ?? []]
@@ -3546,9 +3651,24 @@ async function createLivePlayer(options) {
3546
3651
  },
3547
3652
  async preparePlugins(url) {
3548
3653
  const [typeStrategy, drmStrategy, abrStrategy] = await Promise.all([
3549
- getTypeStrategy({ ...finalOptions, url }, player),
3550
- getDrmStrategy({ ...finalOptions, url }, player),
3551
- getAbrStrategy({ ...finalOptions, url })
3654
+ getTypeStrategy(
3655
+ {
3656
+ ...finalOptions,
3657
+ url
3658
+ },
3659
+ player
3660
+ ),
3661
+ getDrmStrategy(
3662
+ {
3663
+ ...finalOptions,
3664
+ url
3665
+ },
3666
+ player
3667
+ ),
3668
+ getAbrStrategy({
3669
+ ...finalOptions,
3670
+ url
3671
+ })
3552
3672
  ]);
3553
3673
  const { options: options2, plugins } = typeStrategy ?? {};
3554
3674
  const { options: drmOptions, plugins: drmPlugins } = drmStrategy ?? {};
@@ -3566,7 +3686,7 @@ async function createLivePlayer(options) {
3566
3686
  VePlayerLive
3567
3687
  );
3568
3688
  if (player) {
3569
- const RTMDegrade = (_b = (_a = player == null ? void 0 : player._player) == null ? void 0 : _a.config) == null ? void 0 : _b._RTMdegrade;
3689
+ const RTMDegrade = (_d = (_c = player == null ? void 0 : player._player) == null ? void 0 : _c.config) == null ? void 0 : _d._RTMdegrade;
3570
3690
  if (RTMDegrade) {
3571
3691
  player.emit("degrade", {
3572
3692
  originRtmUrl: RTMDegrade._originRtmUrl,
@@ -3602,6 +3722,7 @@ const ListType = window["VePlayer"].ListType;
3602
3722
  setModuleSystem("esm");
3603
3723
  const isMseSupported = util.isMseSupported;
3604
3724
  const isSoftDecodeSupported = util.isSoftDecodeSupported;
3725
+ const isMMSSupported = util.isMMSSupported;
3605
3726
  export {
3606
3727
  Codec,
3607
3728
  DecodeType,
@@ -3615,6 +3736,8 @@ export {
3615
3736
  Sniffer,
3616
3737
  ZH_CN,
3617
3738
  createLivePlayer,
3739
+ isFLVSupported,
3740
+ isMMSSupported,
3618
3741
  isMseSupported,
3619
3742
  isRTMSupportCodec,
3620
3743
  isRTMSupported,