@volcengine/veplayer 2.5.0-rc.0 → 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.
@@ -44,7 +44,7 @@ const strategy$1 = window["VePlayer"].strategy;
44
44
  const util$4 = window["VePlayer"].util;
45
45
  const DynamicModule$3 = window["VePlayer"].DynamicModule;
46
46
  const load$3 = window["VePlayer"].load;
47
- const Codec$1 = window["VePlayer"].Codec;
47
+ const Codec$2 = window["VePlayer"].Codec;
48
48
  const Sniffer$3 = window["VePlayer"].Sniffer;
49
49
  const rtmStrategy = {
50
50
  options: {},
@@ -69,9 +69,9 @@ const getRtmStrategy = async (options, player) => {
69
69
  } = options.rtm || {};
70
70
  const actualFallbackUrl = !enableFallback ? "" : !fallbackUrl && url ? generateFallbackUrl(url) : fallbackUrl;
71
71
  const backupType = actualFallbackUrl && util$4.getStreamType(actualFallbackUrl);
72
- if (backupType === "flv" && util$4.isMseSupported(Codec$1.H264)) {
72
+ if (backupType === "flv" && util$4.isMseSupported(Codec$2.H264)) {
73
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)) {
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$2.H264)) {
75
75
  backupStrategy = strategy$1.createHlsMseStrategy(options);
76
76
  }
77
77
  const [rtmCdn, backupCdn] = await Promise.all([
@@ -542,9 +542,9 @@ function getBrowser() {
542
542
  }
543
543
  return browserInfo;
544
544
  }
545
- var sniffer = {
545
+ var sniffer$1 = {
546
546
  get device() {
547
- var r2 = sniffer.os;
547
+ var r2 = sniffer$1.os;
548
548
  return r2.isPc ? "pc" : "mobile";
549
549
  },
550
550
  get browser() {
@@ -900,7 +900,7 @@ function getCommonLog(options) {
900
900
  codec_type: options.codec_type || "h264",
901
901
  width: Math.floor(player.config.width),
902
902
  height: Math.floor(player.config.height),
903
- browser: sniffer.browser,
903
+ browser: sniffer$1.browser,
904
904
  ua: navigator.userAgent,
905
905
  href: window.location.href,
906
906
  timestamp: 0,
@@ -1042,7 +1042,7 @@ var navigatorConnectionType = function navigatorConnectionType2() {
1042
1042
  var getNetStat = function getNetStat2() {
1043
1043
  if (navgatorOnlineSupported()) {
1044
1044
  if (navigator.onLine) {
1045
- return navigatorConnectionType() || sniffer.device;
1045
+ return navigatorConnectionType() || sniffer$1.device;
1046
1046
  } else {
1047
1047
  return "none";
1048
1048
  }
@@ -1056,7 +1056,7 @@ var LoggerControl = /* @__PURE__ */ function() {
1056
1056
  this.logger = new XgLiveLogger(options);
1057
1057
  this.restart = this.restart.bind(this);
1058
1058
  this.bindUrlChange();
1059
- sniffer.browser.includes("Chrome");
1059
+ sniffer$1.browser.includes("Chrome");
1060
1060
  }
1061
1061
  var _proto = LoggerControl2.prototype;
1062
1062
  _proto.restart = function restart(report_stop) {
@@ -1178,7 +1178,7 @@ var XgLiveLogger = /* @__PURE__ */ function() {
1178
1178
  var player = options.player;
1179
1179
  var isHLS = player.hlsOps !== void 0;
1180
1180
  this.commonParams = _objectSpread2({
1181
- os: sniffer.operation_os
1181
+ os: sniffer$1.operation_os
1182
1182
  }, getCommonLog(options));
1183
1183
  this.log = Object.assign({}, getDefaultLog());
1184
1184
  var self2 = this;
@@ -1250,17 +1250,17 @@ var XgLiveLogger = /* @__PURE__ */ function() {
1250
1250
  }
1251
1251
  };
1252
1252
  _proto2.initWindowListener = function initWindowListener() {
1253
- if (sniffer.device === "pc") {
1253
+ if (sniffer$1.device === "pc") {
1254
1254
  window.addEventListener("beforeunload", this.handleUserLeave);
1255
- } else if (sniffer.device === "mobile") {
1255
+ } else if (sniffer$1.device === "mobile") {
1256
1256
  window.addEventListener("beforeunload", this.handleUserLeave);
1257
1257
  window.addEventListener("pagehide", this.handleUserLeave);
1258
1258
  }
1259
1259
  };
1260
1260
  _proto2.removeWindowListener = function removeWindowListener() {
1261
- if (sniffer.device === "pc") {
1261
+ if (sniffer$1.device === "pc") {
1262
1262
  window.removeEventListener("beforeunload", this.handleUserLeave);
1263
- } else if (sniffer.device === "mobile") {
1263
+ } else if (sniffer$1.device === "mobile") {
1264
1264
  window.removeEventListener("beforeunload", this.handleUserLeave);
1265
1265
  window.removeEventListener("pagehide", this.handleUserLeave);
1266
1266
  }
@@ -1944,9 +1944,9 @@ var XgLiveLogger = /* @__PURE__ */ function() {
1944
1944
  this.handleUserLeave();
1945
1945
  }
1946
1946
  this.destroyed = true;
1947
- if (sniffer.device === "pc") {
1947
+ if (sniffer$1.device === "pc") {
1948
1948
  window.removeEventListener("beforeunload", this.handleUserLeave);
1949
- } else if (sniffer.device === "mobile") {
1949
+ } else if (sniffer$1.device === "mobile") {
1950
1950
  window.removeEventListener("pagehide", this.handleUserLeave);
1951
1951
  }
1952
1952
  videoEvts.forEach(function(name) {
@@ -2990,10 +2990,10 @@ class Logger extends Plugin$2 {
2990
2990
  user_id: this._userId,
2991
2991
  device_id: this._deviceId,
2992
2992
  ext: {
2993
- 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"
2993
+ veplayer_version: "2.3.0",
2994
+ flv_version: "3.0.21-rc.2",
2995
+ hls_version: "3.0.21-rc.2",
2996
+ rts_version: "0.2.1-alpha.12"
2997
2997
  }
2998
2998
  });
2999
2999
  }
@@ -3294,6 +3294,160 @@ const getDrmStrategy = async (options, player) => {
3294
3294
  }
3295
3295
  return {};
3296
3296
  };
3297
+ var VERSION_REG = {
3298
+ android: /(Android)\s([\d.]+)/,
3299
+ ios: /(Version)\/([\d.]+)/
3300
+ };
3301
+ 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"];
3302
+ var sniffer = {
3303
+ get device() {
3304
+ var r2 = sniffer.os;
3305
+ return r2.isPc ? "pc" : "mobile";
3306
+ },
3307
+ get browser() {
3308
+ if (typeof navigator === "undefined") {
3309
+ return "";
3310
+ }
3311
+ var ua = navigator.userAgent.toLowerCase();
3312
+ var reg = {
3313
+ ie: /rv:([\d.]+)\) like gecko/,
3314
+ firefox: /firefox\/([\d.]+)/,
3315
+ chrome: /chrome\/([\d.]+)/,
3316
+ opera: /opera.([\d.]+)/,
3317
+ safari: /version\/([\d.]+).*safari/
3318
+ };
3319
+ return [].concat(Object.keys(reg).filter(function(key) {
3320
+ return reg[key].test(ua);
3321
+ }))[0];
3322
+ },
3323
+ get os() {
3324
+ if (typeof navigator === "undefined") {
3325
+ return {};
3326
+ }
3327
+ var ua = navigator.userAgent;
3328
+ var isWindowsPhone = /(?:Windows Phone)/.test(ua);
3329
+ var isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone;
3330
+ var isAndroid = /(?:Android)/.test(ua);
3331
+ var isFireFox = /(?:Firefox)/.test(ua);
3332
+ var isIpad = /(?:iPad|PlayBook)/.test(ua) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
3333
+ var isTablet = isIpad || isAndroid && !/(?:Mobile)/.test(ua) || isFireFox && /(?:Tablet)/.test(ua);
3334
+ var isPhone = /(?:iPhone)/.test(ua) && !isTablet;
3335
+ var isPc = !isPhone && !isAndroid && !isSymbian && !isTablet;
3336
+ return {
3337
+ isTablet,
3338
+ isPhone,
3339
+ isIpad,
3340
+ isIos: isPhone || isIpad,
3341
+ isAndroid,
3342
+ isPc,
3343
+ isSymbian,
3344
+ isWindowsPhone,
3345
+ isFireFox
3346
+ };
3347
+ },
3348
+ get osVersion() {
3349
+ if (typeof navigator === "undefined") {
3350
+ return 0;
3351
+ }
3352
+ var ua = navigator.userAgent;
3353
+ var reg = "";
3354
+ if (/(?:iPhone)|(?:iPad|PlayBook)/.test(ua)) {
3355
+ reg = VERSION_REG.ios;
3356
+ } else {
3357
+ reg = VERSION_REG.android;
3358
+ }
3359
+ var _match = reg ? reg.exec(ua) : [];
3360
+ if (_match && _match.length >= 3) {
3361
+ var version = _match[2].split(".");
3362
+ return version.length > 0 ? parseInt(version[0]) : 0;
3363
+ }
3364
+ return 0;
3365
+ },
3366
+ get isWeixin() {
3367
+ if (typeof navigator === "undefined") {
3368
+ return false;
3369
+ }
3370
+ var reg = /(micromessenger)\/([\d.]+)/;
3371
+ var match = reg.exec(navigator.userAgent.toLocaleLowerCase());
3372
+ if (match) {
3373
+ return true;
3374
+ }
3375
+ return false;
3376
+ },
3377
+ isSupportMP4: function isSupportMP4() {
3378
+ var result = {
3379
+ isSupport: false,
3380
+ mime: ""
3381
+ };
3382
+ if (typeof document === "undefined") {
3383
+ return result;
3384
+ }
3385
+ if (this.supportResult) {
3386
+ return this.supportResult;
3387
+ }
3388
+ var a2 = document.createElement("video");
3389
+ if (typeof a2.canPlayType === "function") {
3390
+ H264_MIMETYPES.map(function(key) {
3391
+ if (a2.canPlayType('video/mp4; codecs="'.concat(key, '"')) === "probably") {
3392
+ result.isSupport = true;
3393
+ result.mime += "||".concat(key);
3394
+ }
3395
+ });
3396
+ }
3397
+ this.supportResult = result;
3398
+ a2 = null;
3399
+ return result;
3400
+ },
3401
+ isMSESupport: function isMSESupport() {
3402
+ var mime = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';
3403
+ if (typeof MediaSource === "undefined" || !MediaSource)
3404
+ return false;
3405
+ try {
3406
+ return MediaSource.isTypeSupported(mime);
3407
+ } catch (error2) {
3408
+ this._logger.error(mime, error2);
3409
+ return false;
3410
+ }
3411
+ },
3412
+ isHevcSupported: function isHevcSupported() {
3413
+ if (typeof MediaSource === "undefined" || !MediaSource.isTypeSupported) {
3414
+ return false;
3415
+ }
3416
+ 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"');
3417
+ },
3418
+ probeConfigSupported: function probeConfigSupported(info) {
3419
+ var defaults = {
3420
+ supported: false,
3421
+ smooth: false,
3422
+ powerEfficient: false
3423
+ };
3424
+ if (!info || typeof navigator === "undefined") {
3425
+ return Promise.resolve(defaults);
3426
+ }
3427
+ if (navigator.mediaCapabilities && navigator.mediaCapabilities.decodingInfo) {
3428
+ return navigator.mediaCapabilities.decodingInfo(info);
3429
+ } else {
3430
+ var videoConfig = info.video || {};
3431
+ var audioConfig = info.audio || {};
3432
+ try {
3433
+ var videoSupported = MediaSource.isTypeSupported(videoConfig.contentType);
3434
+ var audioSupported = MediaSource.isTypeSupported(audioConfig.contentType);
3435
+ return Promise.resolve({
3436
+ supported: videoSupported && audioSupported,
3437
+ smooth: false,
3438
+ powerEfficient: false
3439
+ });
3440
+ } catch (e3) {
3441
+ return Promise.resolve(defaults);
3442
+ }
3443
+ }
3444
+ }
3445
+ };
3446
+ var Codec$1 = /* @__PURE__ */ ((Codec2) => {
3447
+ Codec2["H265"] = "h265";
3448
+ Codec2["H264"] = "h264";
3449
+ return Codec2;
3450
+ })(Codec$1 || {});
3297
3451
  function isType(suffix) {
3298
3452
  return function(url) {
3299
3453
  return url == null ? void 0 : url.split("?")[0].toLowerCase().includes(suffix);
@@ -3322,6 +3476,15 @@ function getStreamType(url) {
3322
3476
  }
3323
3477
  return "unknown";
3324
3478
  }
3479
+ function isMseSupported$1(codec = Codec$1.H264) {
3480
+ if (codec === Codec$1.H265) {
3481
+ return sniffer.isHevcSupported();
3482
+ }
3483
+ return sniffer.isMSESupport();
3484
+ }
3485
+ function isMMSSupported$1() {
3486
+ return typeof ManagedMediaSource !== "undefined";
3487
+ }
3325
3488
  const DynamicModule$1 = window["VePlayer"].DynamicModule;
3326
3489
  const load$1 = window["VePlayer"].load;
3327
3490
  const getAbrStrategy = async (options) => {
@@ -3361,7 +3524,9 @@ VeI18n.extend([
3361
3524
  }
3362
3525
  ]);
3363
3526
  const LIVE_DEFAULT_OPTIONS = {
3364
- autoplay: { muted: true }
3527
+ autoplay: {
3528
+ muted: true
3529
+ }
3365
3530
  };
3366
3531
  const LIVE_DEFAULT_PLUGINS = [...DEFAULT_PLUGINS, Refresh, Logger, InfoPanel];
3367
3532
  var RTMCodec = /* @__PURE__ */ ((RTMCodec2) => {
@@ -3381,7 +3546,10 @@ class VePlayerLive extends VePlayerBase {
3381
3546
  super(options);
3382
3547
  }
3383
3548
  /** {zh}
3384
- * @brief 获取已经播放的时间
3549
+ * @brief 获取已经播放的时长,不包含暂停和等待时间,单位为秒。
3550
+ */
3551
+ /** {en}
3552
+ * @brief Obtain the duration that has been played, excluding pause and waiting time, with the unit of seconds.
3385
3553
  */
3386
3554
  get playTime() {
3387
3555
  var _a, _b, _c, _d;
@@ -3440,7 +3608,10 @@ class VePlayerLive extends VePlayerBase {
3440
3608
  (_a = this._player.plugins) == null ? void 0 : _a.infopanel.close();
3441
3609
  }
3442
3610
  /** {zh}
3443
- * @brief 打开 Abr
3611
+ * @brief 打开码率自适应(ABR)切换功能。
3612
+ */
3613
+ /** {en}
3614
+ * @brief Enable the Adaptive Bitrate Streaming (ABR) switching feature.
3444
3615
  */
3445
3616
  openAbr() {
3446
3617
  var _a, _b, _c, _d;
@@ -3454,7 +3625,10 @@ class VePlayerLive extends VePlayerBase {
3454
3625
  }
3455
3626
  }
3456
3627
  /** {zh}
3457
- * @brief 关闭 Abr
3628
+ * @brief 关闭码率自适应(ABR)切换功能。
3629
+ */
3630
+ /** {en}
3631
+ * @brief Disable the Adaptive Bitrate Streaming (ABR) switching feature.
3458
3632
  */
3459
3633
  closeAbr() {
3460
3634
  var _a, _b, _c, _d;
@@ -3468,18 +3642,25 @@ class VePlayerLive extends VePlayerBase {
3468
3642
  }
3469
3643
  }
3470
3644
  /** {zh}
3471
- * @brief 调用此方法更新 DRM 鉴权配置。
3472
- * @hidden
3645
+ * @brief 调用此方法更新 DRM 配置。
3646
+ */
3647
+ /** {en}
3648
+ * @brief Use this method to update DRM configuration.
3649
+ * @param config
3473
3650
  */
3474
3651
  updateDrmConfig(config) {
3475
3652
  var _a, _b, _c;
3476
3653
  (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.drm) == null ? void 0 : _c.updateDrmConfig(config);
3477
3654
  }
3478
3655
  /** {zh}
3479
- * @brief 切换 flv Abr
3480
- * @param options 切换 Abr 的配置。
3656
+ * @brief 修改 ABR 配置,包含修改是否开启 ABR 功能,和修改其他清晰度。
3657
+ * @param options ABR 的配置。
3481
3658
  * @returns
3482
3659
  */
3660
+ /** {en}
3661
+ * @brief Modify ABR configuration, including enabling or disabling the ABR feature and adjusting other resolutions.
3662
+ * @param options Configuration of ABR.
3663
+ */
3483
3664
  switchAbr(options) {
3484
3665
  var _a, _b;
3485
3666
  if (!((_a = this._player.plugins) == null ? void 0 : _a.abr)) {
@@ -3490,7 +3671,9 @@ class VePlayerLive extends VePlayerBase {
3490
3671
  if (!url) {
3491
3672
  return;
3492
3673
  }
3493
- this.switch(url, { seamless: true });
3674
+ this.switch(url, {
3675
+ seamless: true
3676
+ });
3494
3677
  this._player.plugins.abr.bitrate = options.bitrate;
3495
3678
  }
3496
3679
  if (typeof (options == null ? void 0 : options.enable) !== "undefined") {
@@ -3498,25 +3681,34 @@ class VePlayerLive extends VePlayerBase {
3498
3681
  }
3499
3682
  }
3500
3683
  /** {zh}
3501
- * @brief 获取 RTM 的网络相关信息
3684
+ * @brief 获取 RTM 拉流的网络评估信息。
3502
3685
  * @returns
3503
3686
  */
3687
+ /** {en}
3688
+ * @brief Obtain the network assessment information of RTM pull streaming.
3689
+ */
3504
3690
  getRTMNetWorkInfo() {
3505
3691
  var _a, _b, _c;
3506
3692
  return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getNetWorkInfo();
3507
3693
  }
3508
3694
  /** {zh}
3509
- * @brief 获取 RTM 播放信息
3695
+ * @brief 获取 RTM 拉流的播放信息。
3510
3696
  * @returns
3511
3697
  */
3698
+ /** {en}
3699
+ * @brief Obtain the playback information of RTM pull stream.
3700
+ */
3512
3701
  async getRTMStats() {
3513
3702
  var _a, _b, _c;
3514
3703
  return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getStatsSnapshoot();
3515
3704
  }
3516
3705
  /** {zh}
3517
- * @brief 获取 FLV 播放信息
3706
+ * @brief 获取 FLV 拉流的播放信息。
3518
3707
  * @returns
3519
3708
  */
3709
+ /** {en}
3710
+ * @brief Obtain the playback information of FLV pull streaming.
3711
+ */
3520
3712
  getFLVStats() {
3521
3713
  var _a, _b, _c;
3522
3714
  return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.flv) == null ? void 0 : _c.getStats();
@@ -3528,7 +3720,10 @@ async function createLivePlayer(options) {
3528
3720
  if (!options || !options.url && !options.playlist) {
3529
3721
  throw create(ErrorCode.INVALID_PARAMETER, new VeI18n());
3530
3722
  }
3531
- const i18n = new VeI18n({ lang: options == null ? void 0 : options.lang, i18n: options == null ? void 0 : options.i18n });
3723
+ const i18n = new VeI18n({
3724
+ lang: options == null ? void 0 : options.lang,
3725
+ i18n: options == null ? void 0 : options.i18n
3726
+ });
3532
3727
  const finalOptions = {
3533
3728
  ...options,
3534
3729
  plugins: [...LIVE_DEFAULT_PLUGINS, ...options.plugins ?? []]
@@ -3546,9 +3741,24 @@ async function createLivePlayer(options) {
3546
3741
  },
3547
3742
  async preparePlugins(url) {
3548
3743
  const [typeStrategy, drmStrategy, abrStrategy] = await Promise.all([
3549
- getTypeStrategy({ ...finalOptions, url }, player),
3550
- getDrmStrategy({ ...finalOptions, url }, player),
3551
- getAbrStrategy({ ...finalOptions, url })
3744
+ getTypeStrategy(
3745
+ {
3746
+ ...finalOptions,
3747
+ url
3748
+ },
3749
+ player
3750
+ ),
3751
+ getDrmStrategy(
3752
+ {
3753
+ ...finalOptions,
3754
+ url
3755
+ },
3756
+ player
3757
+ ),
3758
+ getAbrStrategy({
3759
+ ...finalOptions,
3760
+ url
3761
+ })
3552
3762
  ]);
3553
3763
  const { options: options2, plugins } = typeStrategy ?? {};
3554
3764
  const { options: drmOptions, plugins: drmPlugins } = drmStrategy ?? {};
@@ -3579,6 +3789,9 @@ async function createLivePlayer(options) {
3579
3789
  }
3580
3790
  return player;
3581
3791
  }
3792
+ function isFLVSupported() {
3793
+ return isMseSupported$1() || isMMSSupported$1();
3794
+ }
3582
3795
  var live = /* @__PURE__ */ Object.freeze({
3583
3796
  __proto__: null,
3584
3797
  ErrorCode,
@@ -3602,6 +3815,7 @@ const ListType = window["VePlayer"].ListType;
3602
3815
  setModuleSystem("esm");
3603
3816
  const isMseSupported = util.isMseSupported;
3604
3817
  const isSoftDecodeSupported = util.isSoftDecodeSupported;
3818
+ const isMMSSupported = util.isMMSSupported;
3605
3819
  export {
3606
3820
  Codec,
3607
3821
  DecodeType,
@@ -3615,6 +3829,8 @@ export {
3615
3829
  Sniffer,
3616
3830
  ZH_CN,
3617
3831
  createLivePlayer,
3832
+ isFLVSupported,
3833
+ isMMSSupported,
3618
3834
  isMseSupported,
3619
3835
  isRTMSupportCodec,
3620
3836
  isRTMSupported,