@volcengine/veplayer 2.5.0-rc.1 → 2.5.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.
@@ -48,7 +48,7 @@ var __publicField = (obj, key, value) => {
48
48
  const util$4 = window["VePlayer"].util;
49
49
  const DynamicModule$3 = window["VePlayer"].DynamicModule;
50
50
  const load$3 = window["VePlayer"].load;
51
- const Codec$1 = window["VePlayer"].Codec;
51
+ const Codec$2 = window["VePlayer"].Codec;
52
52
  const Sniffer$3 = window["VePlayer"].Sniffer;
53
53
  const rtmStrategy = {
54
54
  options: {},
@@ -73,9 +73,9 @@ var __publicField = (obj, key, value) => {
73
73
  } = options.rtm || {};
74
74
  const actualFallbackUrl = !enableFallback ? "" : !fallbackUrl && url ? generateFallbackUrl(url) : fallbackUrl;
75
75
  const backupType = actualFallbackUrl && util$4.getStreamType(actualFallbackUrl);
76
- if (backupType === "flv" && util$4.isMseSupported(Codec$1.H264)) {
76
+ if (backupType === "flv" && util$4.isMseSupported(Codec$2.H264)) {
77
77
  backupStrategy = strategy$1.createFlvMseStrategy(options);
78
- } 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)) {
78
+ } else if (backupType === "hls" && (Sniffer$3.device !== "mobile" || ((_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.enableMSE)) && util$4.isMseSupported(Codec$2.H264)) {
79
79
  backupStrategy = strategy$1.createHlsMseStrategy(options);
80
80
  }
81
81
  const [rtmCdn, backupCdn] = await Promise.all([
@@ -546,9 +546,9 @@ var __publicField = (obj, key, value) => {
546
546
  }
547
547
  return browserInfo;
548
548
  }
549
- var sniffer = {
549
+ var sniffer$1 = {
550
550
  get device() {
551
- var r2 = sniffer.os;
551
+ var r2 = sniffer$1.os;
552
552
  return r2.isPc ? "pc" : "mobile";
553
553
  },
554
554
  get browser() {
@@ -904,7 +904,7 @@ var __publicField = (obj, key, value) => {
904
904
  codec_type: options.codec_type || "h264",
905
905
  width: Math.floor(player.config.width),
906
906
  height: Math.floor(player.config.height),
907
- browser: sniffer.browser,
907
+ browser: sniffer$1.browser,
908
908
  ua: navigator.userAgent,
909
909
  href: window.location.href,
910
910
  timestamp: 0,
@@ -1046,7 +1046,7 @@ var __publicField = (obj, key, value) => {
1046
1046
  var getNetStat = function getNetStat2() {
1047
1047
  if (navgatorOnlineSupported()) {
1048
1048
  if (navigator.onLine) {
1049
- return navigatorConnectionType() || sniffer.device;
1049
+ return navigatorConnectionType() || sniffer$1.device;
1050
1050
  } else {
1051
1051
  return "none";
1052
1052
  }
@@ -1060,7 +1060,7 @@ var __publicField = (obj, key, value) => {
1060
1060
  this.logger = new XgLiveLogger(options);
1061
1061
  this.restart = this.restart.bind(this);
1062
1062
  this.bindUrlChange();
1063
- sniffer.browser.includes("Chrome");
1063
+ sniffer$1.browser.includes("Chrome");
1064
1064
  }
1065
1065
  var _proto = LoggerControl2.prototype;
1066
1066
  _proto.restart = function restart(report_stop) {
@@ -1182,7 +1182,7 @@ var __publicField = (obj, key, value) => {
1182
1182
  var player = options.player;
1183
1183
  var isHLS = player.hlsOps !== void 0;
1184
1184
  this.commonParams = _objectSpread2({
1185
- os: sniffer.operation_os
1185
+ os: sniffer$1.operation_os
1186
1186
  }, getCommonLog(options));
1187
1187
  this.log = Object.assign({}, getDefaultLog());
1188
1188
  var self2 = this;
@@ -1254,17 +1254,17 @@ var __publicField = (obj, key, value) => {
1254
1254
  }
1255
1255
  };
1256
1256
  _proto2.initWindowListener = function initWindowListener() {
1257
- if (sniffer.device === "pc") {
1257
+ if (sniffer$1.device === "pc") {
1258
1258
  window.addEventListener("beforeunload", this.handleUserLeave);
1259
- } else if (sniffer.device === "mobile") {
1259
+ } else if (sniffer$1.device === "mobile") {
1260
1260
  window.addEventListener("beforeunload", this.handleUserLeave);
1261
1261
  window.addEventListener("pagehide", this.handleUserLeave);
1262
1262
  }
1263
1263
  };
1264
1264
  _proto2.removeWindowListener = function removeWindowListener() {
1265
- if (sniffer.device === "pc") {
1265
+ if (sniffer$1.device === "pc") {
1266
1266
  window.removeEventListener("beforeunload", this.handleUserLeave);
1267
- } else if (sniffer.device === "mobile") {
1267
+ } else if (sniffer$1.device === "mobile") {
1268
1268
  window.removeEventListener("beforeunload", this.handleUserLeave);
1269
1269
  window.removeEventListener("pagehide", this.handleUserLeave);
1270
1270
  }
@@ -1948,9 +1948,9 @@ var __publicField = (obj, key, value) => {
1948
1948
  this.handleUserLeave();
1949
1949
  }
1950
1950
  this.destroyed = true;
1951
- if (sniffer.device === "pc") {
1951
+ if (sniffer$1.device === "pc") {
1952
1952
  window.removeEventListener("beforeunload", this.handleUserLeave);
1953
- } else if (sniffer.device === "mobile") {
1953
+ } else if (sniffer$1.device === "mobile") {
1954
1954
  window.removeEventListener("pagehide", this.handleUserLeave);
1955
1955
  }
1956
1956
  videoEvts.forEach(function(name) {
@@ -2994,10 +2994,10 @@ var __publicField = (obj, key, value) => {
2994
2994
  user_id: this._userId,
2995
2995
  device_id: this._deviceId,
2996
2996
  ext: {
2997
- veplayer_version: "2.3.1-rc.1",
2998
- flv_version: "3.0.19-rc.0",
2999
- hls_version: "3.0.20-alpha.2",
3000
- rts_version: "0.2.1-alpha.0"
2997
+ veplayer_version: "2.3.0",
2998
+ flv_version: "3.0.21-rc.2",
2999
+ hls_version: "3.0.21-rc.2",
3000
+ rts_version: "0.2.1-alpha.12"
3001
3001
  }
3002
3002
  });
3003
3003
  }
@@ -3298,6 +3298,160 @@ var __publicField = (obj, key, value) => {
3298
3298
  }
3299
3299
  return {};
3300
3300
  };
3301
+ var VERSION_REG = {
3302
+ android: /(Android)\s([\d.]+)/,
3303
+ ios: /(Version)\/([\d.]+)/
3304
+ };
3305
+ var H264_MIMETYPES = ["avc1.42E01E, mp4a.40.2", "avc1.58A01E, mp4a.40.2", "avc1.4D401E, mp4a.40.2", "avc1.64001E, mp4a.40.2", "avc1.42E01E", "mp4v.20.8", "mp4v.20.8, mp4a.40.2", "mp4v.20.240, mp4a.40.2"];
3306
+ var sniffer = {
3307
+ get device() {
3308
+ var r2 = sniffer.os;
3309
+ return r2.isPc ? "pc" : "mobile";
3310
+ },
3311
+ get browser() {
3312
+ if (typeof navigator === "undefined") {
3313
+ return "";
3314
+ }
3315
+ var ua = navigator.userAgent.toLowerCase();
3316
+ var reg = {
3317
+ ie: /rv:([\d.]+)\) like gecko/,
3318
+ firefox: /firefox\/([\d.]+)/,
3319
+ chrome: /chrome\/([\d.]+)/,
3320
+ opera: /opera.([\d.]+)/,
3321
+ safari: /version\/([\d.]+).*safari/
3322
+ };
3323
+ return [].concat(Object.keys(reg).filter(function(key) {
3324
+ return reg[key].test(ua);
3325
+ }))[0];
3326
+ },
3327
+ get os() {
3328
+ if (typeof navigator === "undefined") {
3329
+ return {};
3330
+ }
3331
+ var ua = navigator.userAgent;
3332
+ var isWindowsPhone = /(?:Windows Phone)/.test(ua);
3333
+ var isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone;
3334
+ var isAndroid = /(?:Android)/.test(ua);
3335
+ var isFireFox = /(?:Firefox)/.test(ua);
3336
+ var isIpad = /(?:iPad|PlayBook)/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
3337
+ var isTablet = isIpad || isAndroid && !/(?:Mobile)/.test(ua) || isFireFox && /(?:Tablet)/.test(ua);
3338
+ var isPhone = /(?:iPhone)/.test(ua) && !isTablet;
3339
+ var isPc = !isPhone && !isAndroid && !isSymbian && !isTablet;
3340
+ return {
3341
+ isTablet,
3342
+ isPhone,
3343
+ isIpad,
3344
+ isIos: isPhone || isIpad,
3345
+ isAndroid,
3346
+ isPc,
3347
+ isSymbian,
3348
+ isWindowsPhone,
3349
+ isFireFox
3350
+ };
3351
+ },
3352
+ get osVersion() {
3353
+ if (typeof navigator === "undefined") {
3354
+ return 0;
3355
+ }
3356
+ var ua = navigator.userAgent;
3357
+ var reg = "";
3358
+ if (/(?:iPhone)|(?:iPad|PlayBook)/.test(ua)) {
3359
+ reg = VERSION_REG.ios;
3360
+ } else {
3361
+ reg = VERSION_REG.android;
3362
+ }
3363
+ var _match = reg ? reg.exec(ua) : [];
3364
+ if (_match && _match.length >= 3) {
3365
+ var version = _match[2].split(".");
3366
+ return version.length > 0 ? parseInt(version[0]) : 0;
3367
+ }
3368
+ return 0;
3369
+ },
3370
+ get isWeixin() {
3371
+ if (typeof navigator === "undefined") {
3372
+ return false;
3373
+ }
3374
+ var reg = /(micromessenger)\/([\d.]+)/;
3375
+ var match = reg.exec(navigator.userAgent.toLocaleLowerCase());
3376
+ if (match) {
3377
+ return true;
3378
+ }
3379
+ return false;
3380
+ },
3381
+ isSupportMP4: function isSupportMP4() {
3382
+ var result = {
3383
+ isSupport: false,
3384
+ mime: ""
3385
+ };
3386
+ if (typeof document === "undefined") {
3387
+ return result;
3388
+ }
3389
+ if (this.supportResult) {
3390
+ return this.supportResult;
3391
+ }
3392
+ var a2 = document.createElement("video");
3393
+ if (typeof a2.canPlayType === "function") {
3394
+ H264_MIMETYPES.map(function(key) {
3395
+ if (a2.canPlayType('video/mp4; codecs="'.concat(key, '"')) === "probably") {
3396
+ result.isSupport = true;
3397
+ result.mime += "||".concat(key);
3398
+ }
3399
+ });
3400
+ }
3401
+ this.supportResult = result;
3402
+ a2 = null;
3403
+ return result;
3404
+ },
3405
+ isMSESupport: function isMSESupport() {
3406
+ var mime = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';
3407
+ if (typeof MediaSource === "undefined" || !MediaSource)
3408
+ return false;
3409
+ try {
3410
+ return MediaSource.isTypeSupported(mime);
3411
+ } catch (error2) {
3412
+ this._logger.error(mime, error2);
3413
+ return false;
3414
+ }
3415
+ },
3416
+ isHevcSupported: function isHevcSupported() {
3417
+ if (typeof MediaSource === "undefined" || !MediaSource.isTypeSupported) {
3418
+ return false;
3419
+ }
3420
+ return MediaSource.isTypeSupported('video/mp4;codecs="hev1.1.6.L120.90"') || MediaSource.isTypeSupported('video/mp4;codecs="hev1.2.4.L120.90"') || MediaSource.isTypeSupported('video/mp4;codecs="hev1.3.E.L120.90"') || MediaSource.isTypeSupported('video/mp4;codecs="hev1.4.10.L120.90"');
3421
+ },
3422
+ probeConfigSupported: function probeConfigSupported(info) {
3423
+ var defaults = {
3424
+ supported: false,
3425
+ smooth: false,
3426
+ powerEfficient: false
3427
+ };
3428
+ if (!info || typeof navigator === "undefined") {
3429
+ return Promise.resolve(defaults);
3430
+ }
3431
+ if (navigator.mediaCapabilities && navigator.mediaCapabilities.decodingInfo) {
3432
+ return navigator.mediaCapabilities.decodingInfo(info);
3433
+ } else {
3434
+ var videoConfig = info.video || {};
3435
+ var audioConfig = info.audio || {};
3436
+ try {
3437
+ var videoSupported = MediaSource.isTypeSupported(videoConfig.contentType);
3438
+ var audioSupported = MediaSource.isTypeSupported(audioConfig.contentType);
3439
+ return Promise.resolve({
3440
+ supported: videoSupported && audioSupported,
3441
+ smooth: false,
3442
+ powerEfficient: false
3443
+ });
3444
+ } catch (e2) {
3445
+ return Promise.resolve(defaults);
3446
+ }
3447
+ }
3448
+ }
3449
+ };
3450
+ var Codec$1 = /* @__PURE__ */ ((Codec2) => {
3451
+ Codec2["H265"] = "h265";
3452
+ Codec2["H264"] = "h264";
3453
+ return Codec2;
3454
+ })(Codec$1 || {});
3301
3455
  function isType(suffix) {
3302
3456
  return function(url) {
3303
3457
  return url == null ? void 0 : url.split("?")[0].toLowerCase().includes(suffix);
@@ -3326,6 +3480,15 @@ var __publicField = (obj, key, value) => {
3326
3480
  }
3327
3481
  return "unknown";
3328
3482
  }
3483
+ function isMseSupported$1(codec = Codec$1.H264) {
3484
+ if (codec === Codec$1.H265) {
3485
+ return sniffer.isHevcSupported();
3486
+ }
3487
+ return sniffer.isMSESupport();
3488
+ }
3489
+ function isMMSSupported$1() {
3490
+ return typeof ManagedMediaSource !== "undefined";
3491
+ }
3329
3492
  const DynamicModule$1 = window["VePlayer"].DynamicModule;
3330
3493
  const load$1 = window["VePlayer"].load;
3331
3494
  const getAbrStrategy = async (options) => {
@@ -3365,7 +3528,9 @@ var __publicField = (obj, key, value) => {
3365
3528
  }
3366
3529
  ]);
3367
3530
  const LIVE_DEFAULT_OPTIONS = {
3368
- autoplay: { muted: true }
3531
+ autoplay: {
3532
+ muted: true
3533
+ }
3369
3534
  };
3370
3535
  const LIVE_DEFAULT_PLUGINS = [...DEFAULT_PLUGINS, Refresh, Logger, InfoPanel];
3371
3536
  var RTMCodec = /* @__PURE__ */ ((RTMCodec2) => {
@@ -3385,7 +3550,10 @@ var __publicField = (obj, key, value) => {
3385
3550
  super(options);
3386
3551
  }
3387
3552
  /** {zh}
3388
- * @brief 获取已经播放的时间
3553
+ * @brief 获取已经播放的时长,不包含暂停和等待时间,单位为秒。
3554
+ */
3555
+ /** {en}
3556
+ * @brief Obtain the duration that has been played, excluding pause and waiting time, with the unit of seconds.
3389
3557
  */
3390
3558
  get playTime() {
3391
3559
  var _a, _b, _c, _d;
@@ -3444,7 +3612,10 @@ var __publicField = (obj, key, value) => {
3444
3612
  (_a = this._player.plugins) == null ? void 0 : _a.infopanel.close();
3445
3613
  }
3446
3614
  /** {zh}
3447
- * @brief 打开 Abr
3615
+ * @brief 打开码率自适应(ABR)切换功能。
3616
+ */
3617
+ /** {en}
3618
+ * @brief Enable the Adaptive Bitrate Streaming (ABR) switching feature.
3448
3619
  */
3449
3620
  openAbr() {
3450
3621
  var _a, _b, _c, _d;
@@ -3458,7 +3629,10 @@ var __publicField = (obj, key, value) => {
3458
3629
  }
3459
3630
  }
3460
3631
  /** {zh}
3461
- * @brief 关闭 Abr
3632
+ * @brief 关闭码率自适应(ABR)切换功能。
3633
+ */
3634
+ /** {en}
3635
+ * @brief Disable the Adaptive Bitrate Streaming (ABR) switching feature.
3462
3636
  */
3463
3637
  closeAbr() {
3464
3638
  var _a, _b, _c, _d;
@@ -3472,18 +3646,25 @@ var __publicField = (obj, key, value) => {
3472
3646
  }
3473
3647
  }
3474
3648
  /** {zh}
3475
- * @brief 调用此方法更新 DRM 鉴权配置。
3476
- * @hidden
3649
+ * @brief 调用此方法更新 DRM 配置。
3650
+ */
3651
+ /** {en}
3652
+ * @brief Use this method to update DRM configuration.
3653
+ * @param config
3477
3654
  */
3478
3655
  updateDrmConfig(config) {
3479
3656
  var _a, _b, _c;
3480
3657
  (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.drm) == null ? void 0 : _c.updateDrmConfig(config);
3481
3658
  }
3482
3659
  /** {zh}
3483
- * @brief 切换 flv Abr
3484
- * @param options 切换 Abr 的配置。
3660
+ * @brief 修改 ABR 配置,包含修改是否开启 ABR 功能,和修改其他清晰度。
3661
+ * @param options ABR 的配置。
3485
3662
  * @returns
3486
3663
  */
3664
+ /** {en}
3665
+ * @brief Modify ABR configuration, including enabling or disabling the ABR feature and adjusting other resolutions.
3666
+ * @param options Configuration of ABR.
3667
+ */
3487
3668
  switchAbr(options) {
3488
3669
  var _a, _b;
3489
3670
  if (!((_a = this._player.plugins) == null ? void 0 : _a.abr)) {
@@ -3494,7 +3675,9 @@ var __publicField = (obj, key, value) => {
3494
3675
  if (!url) {
3495
3676
  return;
3496
3677
  }
3497
- this.switch(url, { seamless: true });
3678
+ this.switch(url, {
3679
+ seamless: true
3680
+ });
3498
3681
  this._player.plugins.abr.bitrate = options.bitrate;
3499
3682
  }
3500
3683
  if (typeof (options == null ? void 0 : options.enable) !== "undefined") {
@@ -3502,25 +3685,34 @@ var __publicField = (obj, key, value) => {
3502
3685
  }
3503
3686
  }
3504
3687
  /** {zh}
3505
- * @brief 获取 RTM 的网络相关信息
3688
+ * @brief 获取 RTM 拉流的网络评估信息。
3506
3689
  * @returns
3507
3690
  */
3691
+ /** {en}
3692
+ * @brief Obtain the network assessment information of RTM pull streaming.
3693
+ */
3508
3694
  getRTMNetWorkInfo() {
3509
3695
  var _a, _b, _c;
3510
3696
  return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getNetWorkInfo();
3511
3697
  }
3512
3698
  /** {zh}
3513
- * @brief 获取 RTM 播放信息
3699
+ * @brief 获取 RTM 拉流的播放信息。
3514
3700
  * @returns
3515
3701
  */
3702
+ /** {en}
3703
+ * @brief Obtain the playback information of RTM pull stream.
3704
+ */
3516
3705
  async getRTMStats() {
3517
3706
  var _a, _b, _c;
3518
3707
  return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getStatsSnapshoot();
3519
3708
  }
3520
3709
  /** {zh}
3521
- * @brief 获取 FLV 播放信息
3710
+ * @brief 获取 FLV 拉流的播放信息。
3522
3711
  * @returns
3523
3712
  */
3713
+ /** {en}
3714
+ * @brief Obtain the playback information of FLV pull streaming.
3715
+ */
3524
3716
  getFLVStats() {
3525
3717
  var _a, _b, _c;
3526
3718
  return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.flv) == null ? void 0 : _c.getStats();
@@ -3532,7 +3724,10 @@ var __publicField = (obj, key, value) => {
3532
3724
  if (!options || !options.url && !options.playlist) {
3533
3725
  throw create(ErrorCode.INVALID_PARAMETER, new VeI18n());
3534
3726
  }
3535
- const i18n = new VeI18n({ lang: options == null ? void 0 : options.lang, i18n: options == null ? void 0 : options.i18n });
3727
+ const i18n = new VeI18n({
3728
+ lang: options == null ? void 0 : options.lang,
3729
+ i18n: options == null ? void 0 : options.i18n
3730
+ });
3536
3731
  const finalOptions = {
3537
3732
  ...options,
3538
3733
  plugins: [...LIVE_DEFAULT_PLUGINS, ...options.plugins ?? []]
@@ -3550,9 +3745,24 @@ var __publicField = (obj, key, value) => {
3550
3745
  },
3551
3746
  async preparePlugins(url) {
3552
3747
  const [typeStrategy, drmStrategy, abrStrategy] = await Promise.all([
3553
- getTypeStrategy({ ...finalOptions, url }, player),
3554
- getDrmStrategy({ ...finalOptions, url }, player),
3555
- getAbrStrategy({ ...finalOptions, url })
3748
+ getTypeStrategy(
3749
+ {
3750
+ ...finalOptions,
3751
+ url
3752
+ },
3753
+ player
3754
+ ),
3755
+ getDrmStrategy(
3756
+ {
3757
+ ...finalOptions,
3758
+ url
3759
+ },
3760
+ player
3761
+ ),
3762
+ getAbrStrategy({
3763
+ ...finalOptions,
3764
+ url
3765
+ })
3556
3766
  ]);
3557
3767
  const { options: options2, plugins } = typeStrategy ?? {};
3558
3768
  const { options: drmOptions, plugins: drmPlugins } = drmStrategy ?? {};
@@ -3583,6 +3793,9 @@ var __publicField = (obj, key, value) => {
3583
3793
  }
3584
3794
  return player;
3585
3795
  }
3796
+ function isFLVSupported() {
3797
+ return isMseSupported$1() || isMMSSupported$1();
3798
+ }
3586
3799
  var live = /* @__PURE__ */ Object.freeze({
3587
3800
  __proto__: null,
3588
3801
  ErrorCode,
@@ -3606,6 +3819,7 @@ var __publicField = (obj, key, value) => {
3606
3819
  setModuleSystem("umd");
3607
3820
  const isMseSupported = util.isMseSupported;
3608
3821
  const isSoftDecodeSupported = util.isSoftDecodeSupported;
3822
+ const isMMSSupported = util.isMMSSupported;
3609
3823
  if (typeof VePlayer.registerPlugin !== "undefined") {
3610
3824
  VePlayer.registerPlugin(DynamicModule.BizLive, {
3611
3825
  createLivePlayer
@@ -3627,6 +3841,8 @@ var __publicField = (obj, key, value) => {
3627
3841
  exports2.Sniffer = Sniffer;
3628
3842
  exports2.ZH_CN = ZH_CN;
3629
3843
  exports2.createLivePlayer = createLivePlayer;
3844
+ exports2.isFLVSupported = isFLVSupported;
3845
+ exports2.isMMSSupported = isMMSSupported;
3630
3846
  exports2.isMseSupported = isMseSupported;
3631
3847
  exports2.isRTMSupportCodec = isRTMSupportCodec;
3632
3848
  exports2.isRTMSupported = isRTMSupported;