@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volcengine/veplayer",
3
- "version": "2.5.0",
3
+ "version": "2.5.1-rc.1",
4
4
  "main": "./umd/veplayer.production.js",
5
5
  "module": "./esm/veplayer.production.js",
6
6
  "browser": "./umd/veplayer.production.js",
package/umd/index.d.ts CHANGED
@@ -1399,13 +1399,13 @@ interface VePlayerBaseOptions extends Omit<PlayerOptions, "autoplay" | "i18n"> {
1399
1399
  */
1400
1400
  interface Fullscreen {
1401
1401
  /** {zh}
1402
- * @brief 切换全屏时,是否旋转为横屏播放,通常在移动端使用。如果开启横屏播放,切换全屏时,将在竖屏状态下把播放器旋转 90 度,实现横屏效果。该配置优先级高于 useCssFullscreen。
1403
- * - `true`:使用旋转横屏;
1404
- * - `false`:不使用旋转横屏。
1402
+ * @brief 切换全屏时,是否旋转为横屏播放,通常在移动端使用。如果开启横屏播放,切换全屏时,将在竖屏状态下把播放器旋转 90 度,实现横屏效果。该配置优先级低于 useCssFullscreen。
1403
+ * - `true`:使用旋转横屏;
1404
+ * - `false`:不使用旋转横屏。
1405
1405
  * @default false
1406
1406
  */
1407
1407
  /** {en}
1408
- * @brief Whether to play the video in landscape mode when the video enters full-screen mode. This feature is usually used on mobile devices. Once enabled, when the video enters fullscreen mode, the player will be rotated from portrait mode by 90 degrees to landscape mode. This property has a higher priority over `useCssFullscreen`.
1408
+ * @brief Whether to play the video in landscape mode when the video enters full-screen mode. This feature is usually used on mobile devices. Once enabled, when the video enters fullscreen mode, the player will be rotated from portrait mode by 90 degrees to landscape mode. This property has a lower priority than `useCssFullscreen`.
1409
1409
  * - `true`: Enable.
1410
1410
  * - `false`: Disable.
1411
1411
  * @default false
@@ -3722,13 +3722,13 @@ declare namespace strategy {
3722
3722
  */
3723
3723
  interface Fullscreen {
3724
3724
  /** {zh}
3725
- * @brief 切换全屏时,是否旋转为横屏播放,通常在移动端使用。如果开启横屏播放,切换全屏时,将在竖屏状态下把播放器旋转 90 度,实现横屏效果。该配置优先级高于 useCssFullscreen。
3726
- * - `true`:使用旋转横屏;
3727
- * - `false`:不使用旋转横屏。
3725
+ * @brief 切换全屏时,是否旋转为横屏播放,通常在移动端使用。如果开启横屏播放,切换全屏时,将在竖屏状态下把播放器旋转 90 度,实现横屏效果。该配置优先级低于 useCssFullscreen。
3726
+ * - `true`:使用旋转横屏;
3727
+ * - `false`:不使用旋转横屏。
3728
3728
  * @default false
3729
3729
  */
3730
3730
  /** {en}
3731
- * @brief Whether to play the video in landscape mode when the video enters full-screen mode. This feature is usually used on mobile devices. Once enabled, when the video enters fullscreen mode, the player will be rotated from portrait mode by 90 degrees to landscape mode. This property has a higher priority over `useCssFullscreen`.
3731
+ * @brief Whether to play the video in landscape mode when the video enters full-screen mode. This feature is usually used on mobile devices. Once enabled, when the video enters fullscreen mode, the player will be rotated from portrait mode by 90 degrees to landscape mode. This property has a lower priority than `useCssFullscreen`.
3732
3732
  * - `true`: Enable.
3733
3733
  * - `false`: Disable.
3734
3734
  * @default false
@@ -4002,13 +4002,6 @@ declare namespace strategy {
4002
4002
  function detectCodec(url: string): Promise<"unknown" | Codec>;
4003
4003
  function isSoftDecode(options: VePlayerBaseOptions, currentCodec?: Codec | "unknown"): Promise<boolean>;
4004
4004
  function combineOptions<T = VePlayerBaseOptions>(strategyList: (Strategy<T> | undefined)[]): Partial<T>;
4005
- const getFlvStrategy: (options: VePlayerBaseOptions) => Promise<{
4006
- options?: undefined;
4007
- plugins?: undefined;
4008
- } | {
4009
- options: Partial<VePlayerBaseOptions>;
4010
- plugins: any[];
4011
- }>;
4012
4005
  const getHlsStrategy: (options: VePlayerBaseOptions) => Promise<{
4013
4006
  options?: undefined;
4014
4007
  plugins?: undefined;
@@ -12,6 +12,7 @@ var __publicField = (obj, key, value) => {
12
12
  const { VeError } = error;
13
13
  var LiveErrorCode = /* @__PURE__ */ ((LiveErrorCode2) => {
14
14
  LiveErrorCode2[LiveErrorCode2["INVALID_PARAMETER"] = 210] = "INVALID_PARAMETER";
15
+ LiveErrorCode2[LiveErrorCode2["INVALID_LOGGER"] = 220] = "INVALID_LOGGER";
15
16
  return LiveErrorCode2;
16
17
  })(LiveErrorCode || {});
17
18
  error.Level;
@@ -27,35 +28,48 @@ var __publicField = (obj, key, value) => {
27
28
  ]: {
28
29
  messageTextKey: "INVALID_PARAMETER",
29
30
  level: error.Level.Fatal
31
+ },
32
+ [
33
+ 220
34
+ /* INVALID_LOGGER */
35
+ ]: {
36
+ messageTextKey: "INVALID_LOGGER",
37
+ level: error.Level.Error
30
38
  }
31
39
  };
32
40
  function create(errorCode, i18n) {
33
- return new VeError(ERRORS[errorCode], i18n);
41
+ return new VeError(
42
+ {
43
+ errorCode,
44
+ ...ERRORS[errorCode]
45
+ },
46
+ i18n
47
+ );
34
48
  }
35
49
  const DynamicModule$4 = window["VePlayer"].DynamicModule;
36
- const load$4 = window["VePlayer"].load;
50
+ const load$5 = window["VePlayer"].load;
37
51
  async function isRTMSupported() {
38
- const { RtmPlugin } = await load$4(DynamicModule$4.PluginRtm);
52
+ const { RtmPlugin } = await load$5(DynamicModule$4.PluginRtm);
39
53
  return RtmPlugin.isSupported();
40
54
  }
41
55
  async function isRTMSupportCodec(codec = RTMCodec.H264) {
42
- const { RtmPlugin } = await load$4(DynamicModule$4.PluginRtm);
56
+ const { RtmPlugin } = await load$5(DynamicModule$4.PluginRtm);
43
57
  if (codec === RTMCodec.H264)
44
58
  return RtmPlugin.isSupportedH264();
45
59
  return false;
46
60
  }
47
- const strategy$1 = window["VePlayer"].strategy;
48
- const util$4 = window["VePlayer"].util;
61
+ const strategy$2 = window["VePlayer"].strategy;
62
+ const util$6 = window["VePlayer"].util;
49
63
  const DynamicModule$3 = window["VePlayer"].DynamicModule;
50
- const load$3 = window["VePlayer"].load;
51
- const Codec$2 = window["VePlayer"].Codec;
52
- const Sniffer$3 = window["VePlayer"].Sniffer;
64
+ const load$4 = window["VePlayer"].load;
65
+ const Codec$4 = window["VePlayer"].Codec;
66
+ const Sniffer$5 = window["VePlayer"].Sniffer;
53
67
  const rtmStrategy = {
54
68
  options: {},
55
69
  module: DynamicModule$3.PluginRtm
56
70
  };
57
71
  const generateFallbackUrl = (url) => {
58
- if (Sniffer$3.device === "pc") {
72
+ if (Sniffer$5.device === "pc") {
59
73
  return url.replace(".sdp", ".flv");
60
74
  } else {
61
75
  return url.replace(".sdp", ".m3u8");
@@ -72,17 +86,17 @@ var __publicField = (obj, key, value) => {
72
86
  ...ret
73
87
  } = options.rtm || {};
74
88
  const actualFallbackUrl = !enableFallback ? "" : !fallbackUrl && url ? generateFallbackUrl(url) : fallbackUrl;
75
- const backupType = actualFallbackUrl && util$4.getStreamType(actualFallbackUrl);
76
- if (backupType === "flv" && util$4.isMseSupported(Codec$2.H264)) {
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$2.H264)) {
79
- backupStrategy = strategy$1.createHlsMseStrategy(options);
89
+ const backupType = actualFallbackUrl && util$6.getStreamType(actualFallbackUrl);
90
+ if (backupType === "flv" && util$6.isMseSupported(Codec$4.H264)) {
91
+ backupStrategy = strategy$2.createFlvMseStrategy(options);
92
+ } else if (backupType === "hls" && (Sniffer$5.device !== "mobile" || ((_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.enableMSE)) && util$6.isMseSupported(Codec$4.H264)) {
93
+ backupStrategy = strategy$2.createHlsMseStrategy(options);
80
94
  }
81
95
  const [rtmCdn, backupCdn] = await Promise.all([
82
- load$3(rtmStrategy.module).then((module2) => {
96
+ load$4(rtmStrategy.module).then((module2) => {
83
97
  return module2.RtmPlugin;
84
98
  }).catch(() => void 0),
85
- backupStrategy && load$3(backupStrategy.module).then((module2) => {
99
+ backupStrategy && load$4(backupStrategy.module).then((module2) => {
86
100
  if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule$3.PluginFlv) {
87
101
  return module2.FlvPlugin;
88
102
  } else if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule$3.PluginHls) {
@@ -121,7 +135,7 @@ var __publicField = (obj, key, value) => {
121
135
  return {
122
136
  options: {
123
137
  ...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
124
- url: enableRTMAutoTranscode ? util$4.appendSearchParams(url, { enableRTMAutoTranscode: "true" }) : void 0,
138
+ url: enableRTMAutoTranscode ? util$6.appendSearchParams(url, { enableRTMAutoTranscode: "true" }) : void 0,
125
139
  _RTMdegrade: void 0,
126
140
  rts: {
127
141
  retryCount: 0,
@@ -133,13 +147,13 @@ var __publicField = (obj, key, value) => {
133
147
  plugins: rtmCdn ? [rtmCdn] : []
134
148
  };
135
149
  };
136
- const Sniffer$2 = window["VePlayer"].Sniffer;
150
+ const Sniffer$4 = window["VePlayer"].Sniffer;
137
151
  var DrmType = /* @__PURE__ */ ((DrmType2) => {
138
152
  DrmType2["Fairplay"] = "fairplay";
139
153
  return DrmType2;
140
154
  })(DrmType || {});
141
155
  function getDrmType(drm) {
142
- if ((drm == null ? void 0 : drm.fairplay) && (Sniffer$2.browser === "safari" || Sniffer$2.os.isIos)) {
156
+ if ((drm == null ? void 0 : drm.fairplay) && (Sniffer$4.browser === "safari" || Sniffer$4.os.isIos)) {
143
157
  return "fairplay";
144
158
  }
145
159
  return;
@@ -157,6 +171,63 @@ var __publicField = (obj, key, value) => {
157
171
  }
158
172
  return true;
159
173
  }
174
+ const Sniffer$3 = window["VePlayer"].Sniffer;
175
+ const Codec$3 = window["VePlayer"].Codec;
176
+ const util$5 = window["VePlayer"].util;
177
+ const { isMMSSupported: isMMSSupported$2, isMseSupported: isMseSupported$2 } = util$5;
178
+ function enableMMS() {
179
+ return Sniffer$3.os.isIos;
180
+ }
181
+ function isFLVSupported$1(codec = Codec$3.H264) {
182
+ const isMediaSourceSupported = enableMMS() ? isMMSSupported$2 : isMseSupported$2;
183
+ return isMediaSourceSupported(codec);
184
+ }
185
+ const strategy$1 = window["VePlayer"].strategy;
186
+ const load$3 = window["VePlayer"].load;
187
+ const Sniffer$2 = window["VePlayer"].Sniffer;
188
+ const Codec$2 = window["VePlayer"].Codec;
189
+ const util$4 = window["VePlayer"].util;
190
+ const { appendSearchParams } = util$4;
191
+ const getFlvStrategy = async (options) => {
192
+ var _a, _b, _c, _d, _e, _f;
193
+ let mseStrategy;
194
+ let softStrategy;
195
+ const enableLowLatency = ((_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.enableLowLatency) && Sniffer$2.device === "pc";
196
+ const enableFrameChasing = ((_c = (_b = options == null ? void 0 : options.flv) == null ? void 0 : _b.lowLatency) == null ? void 0 : _c.enableFrameChasing) ?? true;
197
+ const abrPts = ((_e = (_d = options == null ? void 0 : options.flv) == null ? void 0 : _d.lowLatency) == null ? void 0 : _e.abrPts) ?? "-800";
198
+ const codec = await strategy$1.getCodec(options);
199
+ const isSoftDecode = await strategy$1.isSoftDecode(options, codec);
200
+ if (isSoftDecode) {
201
+ softStrategy = codec === Codec$2.H265 ? strategy$1.createSoftDecodeH265Strategy() : strategy$1.createSoftDecodeH264Strategy();
202
+ mseStrategy = strategy$1.createFlvMseStrategy(options);
203
+ }
204
+ if (codec === "unknown" ? isFLVSupported$1(Codec$2.H264) : isFLVSupported$1(codec)) {
205
+ mseStrategy = enableMMS() ? strategy$1.createFlvMssStrategy(options) : strategy$1.createFlvMseStrategy(options);
206
+ }
207
+ if (!mseStrategy && !softStrategy) {
208
+ return {};
209
+ }
210
+ const [mseModule, softModule] = await Promise.all([
211
+ (mseStrategy == null ? void 0 : mseStrategy.module) && load$3(mseStrategy.module).catch(() => void 0),
212
+ (softStrategy == null ? void 0 : softStrategy.module) && load$3(softStrategy.module).catch(() => void 0)
213
+ ]);
214
+ (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));
215
+ const combineOptions = strategy$1.combineOptions([mseStrategy, softStrategy]);
216
+ const plugins = [];
217
+ if (enableLowLatency) {
218
+ combineOptions.url = appendSearchParams(options.url, { abr_pts: abrPts });
219
+ }
220
+ if (mseModule) {
221
+ plugins.push(mseModule.FlvPlugin);
222
+ if (enableLowLatency && enableFrameChasing) {
223
+ plugins.push(mseModule.Adaptive);
224
+ }
225
+ }
226
+ return {
227
+ options: combineOptions,
228
+ plugins
229
+ };
230
+ };
160
231
  const util$3 = window["VePlayer"].util;
161
232
  const strategy = window["VePlayer"].strategy;
162
233
  const getTypeStrategy = async (options, player) => {
@@ -168,7 +239,7 @@ var __publicField = (obj, key, value) => {
168
239
  return await getRtmStrategy(options, player);
169
240
  }
170
241
  if (type === "flv") {
171
- return await strategy.getFlvStrategy(options);
242
+ return await getFlvStrategy(options);
172
243
  }
173
244
  if (type === "hls") {
174
245
  if (!isMseSupportedWithDrm({ drm: options.drm, streamType: type })) {
@@ -2932,7 +3003,7 @@ var __publicField = (obj, key, value) => {
2932
3003
  }
2933
3004
  static get defaultConfig() {
2934
3005
  return {
2935
- appId: "",
3006
+ appId: 654925,
2936
3007
  enable: true,
2937
3008
  showUserIdInErrorPanel: true
2938
3009
  };
@@ -2942,10 +3013,6 @@ var __publicField = (obj, key, value) => {
2942
3013
  if (!this.config.enable) {
2943
3014
  return;
2944
3015
  }
2945
- if (!this.config.appId) {
2946
- console.info("not found appId, please generate an appId");
2947
- return;
2948
- }
2949
3016
  this._userId = ((_a = this.config) == null ? void 0 : _a.userId) || getUserId();
2950
3017
  this._deviceId = ((_b = this.config) == null ? void 0 : _b.deviceId) || getDeviceID();
2951
3018
  this.open();
@@ -2988,16 +3055,17 @@ var __publicField = (obj, key, value) => {
2988
3055
  this._liveLogger = new LoggerControl({
2989
3056
  Tea: q,
2990
3057
  player: this.player,
2991
- aid: this.config.appId,
3058
+ aid: this.config.appId || 654925,
2992
3059
  project_key: this.config.appId,
2993
3060
  app_name: this.config.appName || this.config.appId,
2994
3061
  user_id: this._userId,
2995
3062
  device_id: this._deviceId,
3063
+ error_report_stop: true,
2996
3064
  ext: {
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"
3065
+ veplayer_version: "2.3.1-rc.1",
3066
+ flv_version: "3.0.21-rc.5",
3067
+ hls_version: "3.0.21-rc.5",
3068
+ rts_version: "0.2.1-alpha.14"
3001
3069
  }
3002
3070
  });
3003
3071
  }
@@ -3233,6 +3301,7 @@ var __publicField = (obj, key, value) => {
3233
3301
  const EN$1 = {
3234
3302
  ...BaseEN,
3235
3303
  INVALID_PARAMETER: "The imported parameter is empty, please pass in necessary parameters such as the stream address",
3304
+ 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.",
3236
3305
  // info-panel
3237
3306
  FORMAT: "format",
3238
3307
  FPS: "fps",
@@ -3251,6 +3320,7 @@ var __publicField = (obj, key, value) => {
3251
3320
  const ZH_CN$1 = {
3252
3321
  ...BaseZH_CN,
3253
3322
  INVALID_PARAMETER: "入参为空,请传入流地址等必要参数",
3323
+ INVALID_LOGGER: "未正确配置质量日志参数, 请参考 https://www.volcengine.com/docs/6469/138655#日志上报 配置",
3254
3324
  // info-panel
3255
3325
  FORMAT: "格式",
3256
3326
  FPS: "帧率",
@@ -3452,6 +3522,13 @@ var __publicField = (obj, key, value) => {
3452
3522
  Codec2["H264"] = "h264";
3453
3523
  return Codec2;
3454
3524
  })(Codec$1 || {});
3525
+ const H264_MIME = 'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';
3526
+ const H265_MIME = [
3527
+ 'video/mp4;codecs="hev1.1.6.L120.90"',
3528
+ 'video/mp4;codecs="hev1.2.4.L120.90"',
3529
+ 'video/mp4;codecs="hev1.3.E.L120.90"',
3530
+ 'video/mp4;codecs="hev1.4.10.L120.90"'
3531
+ ];
3455
3532
  function isType(suffix) {
3456
3533
  return function(url) {
3457
3534
  return url == null ? void 0 : url.split("?")[0].toLowerCase().includes(suffix);
@@ -3484,10 +3561,24 @@ var __publicField = (obj, key, value) => {
3484
3561
  if (codec === Codec$1.H265) {
3485
3562
  return sniffer.isHevcSupported();
3486
3563
  }
3487
- return sniffer.isMSESupport();
3564
+ if (codec === Codec$1.H264) {
3565
+ return sniffer.isMSESupport();
3566
+ }
3567
+ return sniffer.isMSESupport(codec);
3488
3568
  }
3489
- function isMMSSupported$1() {
3490
- return typeof ManagedMediaSource !== "undefined";
3569
+ function isMMSSupported$1(codec = Codec$1.H264) {
3570
+ if (typeof window.ManagedMediaSource === "undefined") {
3571
+ return false;
3572
+ }
3573
+ if (codec === Codec$1.H264) {
3574
+ return window.ManagedMediaSource.isTypeSupported(H264_MIME);
3575
+ }
3576
+ if (codec === Codec$1.H265) {
3577
+ return H265_MIME.some((mine) => {
3578
+ return window.ManagedMediaSource.isTypeSupported(mine);
3579
+ });
3580
+ }
3581
+ return window.ManagedMediaSource.isTypeSupported(codec);
3491
3582
  }
3492
3583
  const DynamicModule$1 = window["VePlayer"].DynamicModule;
3493
3584
  const load$1 = window["VePlayer"].load;
@@ -3719,15 +3810,18 @@ var __publicField = (obj, key, value) => {
3719
3810
  }
3720
3811
  }
3721
3812
  async function createLivePlayer(options) {
3722
- var _a, _b;
3813
+ var _a, _b, _c, _d;
3723
3814
  let player = void 0;
3724
- if (!options || !options.url && !options.playlist) {
3725
- throw create(ErrorCode.INVALID_PARAMETER, new VeI18n());
3726
- }
3727
3815
  const i18n = new VeI18n({
3728
3816
  lang: options == null ? void 0 : options.lang,
3729
3817
  i18n: options == null ? void 0 : options.i18n
3730
3818
  });
3819
+ if (!options || !options.url && !options.playlist) {
3820
+ throw create(ErrorCode.INVALID_PARAMETER, i18n);
3821
+ }
3822
+ if (!((_a = options.logger) == null ? void 0 : _a.appId) && ((_b = options == null ? void 0 : options.logger) == null ? void 0 : _b.enable) !== false) {
3823
+ console.warn(create(ErrorCode.INVALID_LOGGER, i18n).message);
3824
+ }
3731
3825
  const finalOptions = {
3732
3826
  ...options,
3733
3827
  plugins: [...LIVE_DEFAULT_PLUGINS, ...options.plugins ?? []]
@@ -3780,7 +3874,7 @@ var __publicField = (obj, key, value) => {
3780
3874
  VePlayerLive
3781
3875
  );
3782
3876
  if (player) {
3783
- const RTMDegrade = (_b = (_a = player == null ? void 0 : player._player) == null ? void 0 : _a.config) == null ? void 0 : _b._RTMdegrade;
3877
+ const RTMDegrade = (_d = (_c = player == null ? void 0 : player._player) == null ? void 0 : _c.config) == null ? void 0 : _d._RTMdegrade;
3784
3878
  if (RTMDegrade) {
3785
3879
  player.emit("degrade", {
3786
3880
  originRtmUrl: RTMDegrade._originRtmUrl,