@volcengine/veplayer 2.4.0 → 2.4.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.
@@ -40,15 +40,72 @@ async function isRTMSupportCodec(codec = RTMCodec.H264) {
40
40
  return RtmPlugin.isSupportedH264();
41
41
  return false;
42
42
  }
43
- const strategy$1 = window["VePlayer"].strategy;
44
- const util$4 = window["VePlayer"].util;
43
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
44
+ function getDefaultExportFromCjs(x2) {
45
+ return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
46
+ }
47
+ function isType(suffix) {
48
+ return function(url) {
49
+ return url == null ? void 0 : url.split("?")[0].toLowerCase().includes(suffix);
50
+ };
51
+ }
52
+ const isHls = isType(".m3u8");
53
+ const isMp4 = isType(".mp4");
54
+ const isFlv = isType(".flv");
55
+ const isRtm = isType(".sdp");
56
+ const isDash = isType(".mpd");
57
+ function getStreamType(url) {
58
+ if (isHls(url)) {
59
+ return "hls";
60
+ }
61
+ if (isFlv(url)) {
62
+ return "flv";
63
+ }
64
+ if (isRtm(url)) {
65
+ return "rtm";
66
+ }
67
+ if (isMp4(url)) {
68
+ return "mp4";
69
+ }
70
+ if (isDash(url)) {
71
+ return "dash";
72
+ }
73
+ return "unknown";
74
+ }
45
75
  const DynamicModule$3 = window["VePlayer"].DynamicModule;
46
76
  const load$3 = window["VePlayer"].load;
77
+ const getAbrStrategy = async (options) => {
78
+ var _a, _b;
79
+ const streamType = options.url && getStreamType(options.url);
80
+ if (streamType === "rtm") {
81
+ return {};
82
+ }
83
+ const abrOptions = streamType === "flv" ? (_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.abr : (_b = options == null ? void 0 : options.hls) == null ? void 0 : _b.abr;
84
+ if (!abrOptions) {
85
+ return {};
86
+ }
87
+ const abrPlugin = await load$3(DynamicModule$3.PluginAbr).catch(() => void 0);
88
+ return {
89
+ options: {
90
+ [streamType === "flv" ? "abr" : "hlsabr"]: {
91
+ ...abrOptions,
92
+ open: abrOptions.enable ?? true
93
+ }
94
+ },
95
+ plugins: [
96
+ streamType === "flv" ? abrPlugin == null ? void 0 : abrPlugin.AbrPlugin : abrPlugin == null ? void 0 : abrPlugin.HlsAbrPlugin
97
+ ]
98
+ };
99
+ };
100
+ const strategy$1 = window["VePlayer"].strategy;
101
+ const util$4 = window["VePlayer"].util;
102
+ const DynamicModule$2 = window["VePlayer"].DynamicModule;
103
+ const load$2 = window["VePlayer"].load;
47
104
  const Codec$1 = window["VePlayer"].Codec;
48
105
  const Sniffer$3 = window["VePlayer"].Sniffer;
49
106
  const rtmStrategy = {
50
107
  options: {},
51
- module: DynamicModule$3.PluginRtm
108
+ module: DynamicModule$2.PluginRtm
52
109
  };
53
110
  const generateFallbackUrl = (url) => {
54
111
  if (Sniffer$3.device === "pc") {
@@ -60,6 +117,8 @@ const generateFallbackUrl = (url) => {
60
117
  const getRtmStrategy = async (options, player) => {
61
118
  var _a;
62
119
  let backupStrategy;
120
+ let backupOptions = {};
121
+ let backupModule = [];
63
122
  const { url } = options;
64
123
  const {
65
124
  fallbackUrl,
@@ -74,18 +133,28 @@ const getRtmStrategy = async (options, player) => {
74
133
  } 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
134
  backupStrategy = strategy$1.createHlsMseStrategy(options);
76
135
  }
77
- const [rtmCdn, backupCdn] = await Promise.all([
78
- load$3(rtmStrategy.module).then((module) => {
136
+ const [rtmCdn, backupCdn, backupAbr] = await Promise.all([
137
+ load$2(rtmStrategy.module).then((module) => {
79
138
  return module.RtmPlugin;
80
139
  }).catch(() => void 0),
81
- backupStrategy && load$3(backupStrategy.module).then((module) => {
82
- if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule$3.PluginFlv) {
140
+ backupStrategy && load$2(backupStrategy.module).then((module) => {
141
+ if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule$2.PluginFlv) {
83
142
  return module.FlvPlugin;
84
- } else if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule$3.PluginHls) {
143
+ } else if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule$2.PluginHls) {
85
144
  return module.HlsPlugin;
86
145
  }
87
- }).catch(() => void 0)
146
+ }).catch(() => void 0),
147
+ getAbrStrategy({ ...options, url: actualFallbackUrl }).catch(
148
+ () => void 0
149
+ )
88
150
  ]);
151
+ if (backupType) {
152
+ backupOptions = {
153
+ ...backupStrategy == null ? void 0 : backupStrategy.options,
154
+ ...backupAbr == null ? void 0 : backupAbr.options
155
+ };
156
+ backupModule = [backupCdn, ...(backupAbr == null ? void 0 : backupAbr.plugins) ?? []];
157
+ }
89
158
  const [RTMSupported, RTMSupportCodec] = await Promise.all([
90
159
  isRTMSupported(),
91
160
  isRTMSupportCodec()
@@ -103,7 +172,7 @@ const getRtmStrategy = async (options, player) => {
103
172
  }
104
173
  return {
105
174
  options: {
106
- ...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
175
+ ...backupOptions || {},
107
176
  url: actualFallbackUrl,
108
177
  _RTMdegrade: {
109
178
  _originRtmUrl: url,
@@ -111,19 +180,19 @@ const getRtmStrategy = async (options, player) => {
111
180
  _isRTMSupportCodec: RTMSupportCodec
112
181
  }
113
182
  },
114
- plugins: backupCdn ? [backupCdn] : []
183
+ plugins: backupModule
115
184
  };
116
185
  }
117
186
  return {
118
187
  options: {
119
- ...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
188
+ ...backupOptions || {},
120
189
  url: enableRTMAutoTranscode ? util$4.appendSearchParams(url, { enableRTMAutoTranscode: "true" }) : void 0,
121
190
  _RTMdegrade: void 0,
122
191
  rts: {
123
192
  retryCount: 0,
124
193
  ...ret,
125
194
  backupURL: actualFallbackUrl,
126
- backupConstruct: backupCdn
195
+ backupConstruct: backupModule
127
196
  }
128
197
  },
129
198
  plugins: rtmCdn ? [rtmCdn] : []
@@ -174,10 +243,6 @@ const getTypeStrategy = async (options, player) => {
174
243
  }
175
244
  return { options: {}, plugins: [] };
176
245
  };
177
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
178
- function getDefaultExportFromCjs(x2) {
179
- return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
180
- }
181
246
  var FUNC_ERROR_TEXT = "Expected a function";
182
247
  var NAN = 0 / 0;
183
248
  var symbolTag = "[object Symbol]";
@@ -2990,10 +3055,10 @@ class Logger extends Plugin$2 {
2990
3055
  user_id: this._userId,
2991
3056
  device_id: this._deviceId,
2992
3057
  ext: {
2993
- veplayer_version: "2.3.0",
2994
- flv_version: "3.0.19-rc.0",
3058
+ veplayer_version: "2.3.1-rc.1",
3059
+ flv_version: "3.0.19-rc.10",
2995
3060
  hls_version: "3.0.19-rc.0",
2996
- rts_version: "0.2.1-alpha.0"
3061
+ rts_version: "0.2.1-alpha.1"
2997
3062
  }
2998
3063
  });
2999
3064
  }
@@ -3261,8 +3326,8 @@ const ZH_CN$1 = {
3261
3326
  DECODE_INFO: "软解信息",
3262
3327
  REFRESH: "刷新"
3263
3328
  };
3264
- const DynamicModule$2 = window["VePlayer"].DynamicModule;
3265
- const load$2 = window["VePlayer"].load;
3329
+ const DynamicModule$1 = window["VePlayer"].DynamicModule;
3330
+ const load$1 = window["VePlayer"].load;
3266
3331
  const getDrmStrategy = async (options, player) => {
3267
3332
  var _a;
3268
3333
  const drmType = getDrmType(options.drm);
@@ -3270,7 +3335,7 @@ const getDrmStrategy = async (options, player) => {
3270
3335
  try {
3271
3336
  const { getDrmConfig, ...originFairplayConfig } = ((_a = options == null ? void 0 : options.drm) == null ? void 0 : _a.fairplay) ?? {};
3272
3337
  const [drmPlugin, drmConfig] = await Promise.all([
3273
- load$2(DynamicModule$2.PluginDrm).then((module) => module.DrmPlugin).catch(() => void 0),
3338
+ load$1(DynamicModule$1.PluginDrm).then((module) => module.DrmPlugin).catch(() => void 0),
3274
3339
  getDrmConfig == null ? void 0 : getDrmConfig({
3275
3340
  url: options.url
3276
3341
  })
@@ -3294,59 +3359,6 @@ const getDrmStrategy = async (options, player) => {
3294
3359
  }
3295
3360
  return {};
3296
3361
  };
3297
- function isType(suffix) {
3298
- return function(url) {
3299
- return url == null ? void 0 : url.split("?")[0].toLowerCase().includes(suffix);
3300
- };
3301
- }
3302
- const isHls = isType(".m3u8");
3303
- const isMp4 = isType(".mp4");
3304
- const isFlv = isType(".flv");
3305
- const isRtm = isType(".sdp");
3306
- const isDash = isType(".mpd");
3307
- function getStreamType(url) {
3308
- if (isHls(url)) {
3309
- return "hls";
3310
- }
3311
- if (isFlv(url)) {
3312
- return "flv";
3313
- }
3314
- if (isRtm(url)) {
3315
- return "rtm";
3316
- }
3317
- if (isMp4(url)) {
3318
- return "mp4";
3319
- }
3320
- if (isDash(url)) {
3321
- return "dash";
3322
- }
3323
- return "unknown";
3324
- }
3325
- const DynamicModule$1 = window["VePlayer"].DynamicModule;
3326
- const load$1 = window["VePlayer"].load;
3327
- const getAbrStrategy = async (options) => {
3328
- var _a, _b;
3329
- const streamType = options.url && getStreamType(options.url);
3330
- if (streamType === "rtm") {
3331
- return {};
3332
- }
3333
- const abrOptions = streamType === "flv" ? (_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.abr : (_b = options == null ? void 0 : options.hls) == null ? void 0 : _b.abr;
3334
- if (!abrOptions) {
3335
- return {};
3336
- }
3337
- const abrPlugin = await load$1(DynamicModule$1.PluginAbr).catch(() => void 0);
3338
- return {
3339
- options: {
3340
- [streamType === "flv" ? "abr" : "hlsabr"]: {
3341
- ...abrOptions,
3342
- open: abrOptions.enable ?? true
3343
- }
3344
- },
3345
- plugins: [
3346
- streamType === "flv" ? abrPlugin == null ? void 0 : abrPlugin.AbrPlugin : abrPlugin == null ? void 0 : abrPlugin.HlsAbrPlugin
3347
- ]
3348
- };
3349
- };
3350
3362
  const DEFAULT_PLUGINS = window["VePlayer"].DEFAULT_PLUGINS;
3351
3363
  const VePlayerBase = window["VePlayer"].VePlayerBase;
3352
3364
  const VeI18n = window["VePlayer"].VeI18n;