@volcengine/veplayer 2.6.1 → 2.7.0-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.
- package/esm/index.d.ts +41 -119
- package/esm/veplayer.biz.live.development.js +957 -328
- package/esm/veplayer.biz.live.production.js +1 -1
- package/esm/veplayer.d.ts +336 -200
- package/esm/veplayer.development.js +918 -317
- package/esm/veplayer.live.d.ts +336 -200
- package/esm/veplayer.live.development.js +917 -316
- package/esm/veplayer.live.production.js +3 -3
- package/esm/veplayer.production.js +3 -3
- package/esm/veplayer.vod.d.ts +41 -119
- package/esm/veplayer.vod.development.js +37 -21
- package/esm/veplayer.vod.production.js +2 -2
- package/package.json +1 -1
- package/umd/index.d.ts +41 -119
- package/umd/veplayer.biz.live.development.js +957 -328
- package/umd/veplayer.biz.live.production.js +1 -1
- package/umd/veplayer.d.ts +336 -200
- package/umd/veplayer.development.js +918 -317
- package/umd/veplayer.live.d.ts +336 -200
- package/umd/veplayer.live.development.js +917 -316
- package/umd/veplayer.live.production.js +1 -1
- package/umd/veplayer.production.js +1 -1
- package/umd/veplayer.vod.d.ts +41 -119
- package/umd/veplayer.vod.development.js +37 -21
- package/umd/veplayer.vod.production.js +1 -1
- package/veplayer.d.ts +336 -200
- package/veplayer.live.d.ts +336 -200
- package/veplayer.vod.d.ts +41 -119
|
@@ -50,235 +50,6 @@ function create(errorCode, i18n) {
|
|
|
50
50
|
i18n
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
|
-
const DynamicModule$4 = window["VePlayer"].DynamicModule;
|
|
54
|
-
const load$5 = window["VePlayer"].load;
|
|
55
|
-
async function isRTMSupported() {
|
|
56
|
-
const { RtmPlugin } = await load$5(DynamicModule$4.PluginRtm);
|
|
57
|
-
return RtmPlugin.isSupported();
|
|
58
|
-
}
|
|
59
|
-
async function isRTMSupportCodec(codec = RTMCodec.H264) {
|
|
60
|
-
const { RtmPlugin } = await load$5(DynamicModule$4.PluginRtm);
|
|
61
|
-
if (codec === RTMCodec.H264)
|
|
62
|
-
return RtmPlugin.isSupportedH264();
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
const getUrlObject = (url) => {
|
|
66
|
-
if (!url) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const withoutProtocol = url.startsWith("//");
|
|
70
|
-
if (withoutProtocol) {
|
|
71
|
-
url = location.protocol + url;
|
|
72
|
-
}
|
|
73
|
-
try {
|
|
74
|
-
return new URL(url);
|
|
75
|
-
} catch (error2) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
const strategy$2 = window["VePlayer"].strategy;
|
|
80
|
-
const util$6 = window["VePlayer"].util;
|
|
81
|
-
const DynamicModule$3 = window["VePlayer"].DynamicModule;
|
|
82
|
-
const load$4 = window["VePlayer"].load;
|
|
83
|
-
const Codec$3 = window["VePlayer"].Codec;
|
|
84
|
-
const Sniffer$4 = window["VePlayer"].Sniffer;
|
|
85
|
-
const rtmStrategy = {
|
|
86
|
-
options: {},
|
|
87
|
-
module: DynamicModule$3.PluginRtm
|
|
88
|
-
};
|
|
89
|
-
const generateFallbackUrl = (url) => {
|
|
90
|
-
if (Sniffer$4.device === "pc") {
|
|
91
|
-
return url.replace(".sdp", ".flv");
|
|
92
|
-
} else {
|
|
93
|
-
return url.replace(".sdp", ".m3u8");
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
const getRtmStrategy = async (options, player, i18n) => {
|
|
97
|
-
var _a, _b;
|
|
98
|
-
let backupStrategy;
|
|
99
|
-
let actualFallbackUrl = "";
|
|
100
|
-
const { url, playlist } = options;
|
|
101
|
-
const { fallbackUrl, enableRTMAutoTranscode, ...ret } = options.rtm || {};
|
|
102
|
-
let { enableFallback = true } = options.rtm || {};
|
|
103
|
-
if (playlist == null ? void 0 : playlist.length) {
|
|
104
|
-
enableFallback = false;
|
|
105
|
-
}
|
|
106
|
-
const isRTMAutoTranscode = enableRTMAutoTranscode || ((_a = getUrlObject(url)) == null ? void 0 : _a.searchParams.get("enableRTMAutoTranscode")) === "true";
|
|
107
|
-
if (enableFallback) {
|
|
108
|
-
if (fallbackUrl) {
|
|
109
|
-
actualFallbackUrl = fallbackUrl;
|
|
110
|
-
} else if (isRTMAutoTranscode && url) {
|
|
111
|
-
actualFallbackUrl = generateFallbackUrl(url);
|
|
112
|
-
} else {
|
|
113
|
-
console.warn(
|
|
114
|
-
create(ErrorCode.EMPTY_RTM_FALLBACK_PARAMETER, i18n).message
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
const backupType = actualFallbackUrl && util$6.getStreamType(actualFallbackUrl);
|
|
119
|
-
if (backupType === "flv" && util$6.isMseSupported(Codec$3.H264)) {
|
|
120
|
-
backupStrategy = strategy$2.createFlvMseStrategy(options);
|
|
121
|
-
} else if (backupType === "hls" && (Sniffer$4.device !== "mobile" || ((_b = options == null ? void 0 : options.hls) == null ? void 0 : _b.enableMSE)) && util$6.isMseSupported(Codec$3.H264)) {
|
|
122
|
-
backupStrategy = strategy$2.createHlsMseStrategy(options);
|
|
123
|
-
}
|
|
124
|
-
const [rtmCdn, backupCdn] = await Promise.all([
|
|
125
|
-
load$4(rtmStrategy.module).then((module) => {
|
|
126
|
-
return module.RtmPlugin;
|
|
127
|
-
}).catch(() => void 0),
|
|
128
|
-
backupStrategy && load$4(backupStrategy.module).then((module) => {
|
|
129
|
-
if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule$3.PluginFlv) {
|
|
130
|
-
return module.FlvPlugin;
|
|
131
|
-
} else if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule$3.PluginHls) {
|
|
132
|
-
return module.HlsPlugin;
|
|
133
|
-
}
|
|
134
|
-
}).catch(() => void 0)
|
|
135
|
-
]);
|
|
136
|
-
if (actualFallbackUrl) {
|
|
137
|
-
const [RTMSupported, RTMSupportCodec] = await Promise.all([
|
|
138
|
-
isRTMSupported(),
|
|
139
|
-
isRTMSupportCodec()
|
|
140
|
-
]);
|
|
141
|
-
if (!RTMSupported || !RTMSupportCodec) {
|
|
142
|
-
if (player) {
|
|
143
|
-
player.emit("degrade", {
|
|
144
|
-
url: actualFallbackUrl,
|
|
145
|
-
originRtmUrl: url,
|
|
146
|
-
code: "NOT_SUPPORT",
|
|
147
|
-
message: "not support rtm or h264",
|
|
148
|
-
isRTMSupported: RTMSupported,
|
|
149
|
-
isRTMSupportCodec: RTMSupportCodec
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
return {
|
|
153
|
-
options: {
|
|
154
|
-
...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
|
|
155
|
-
url: actualFallbackUrl,
|
|
156
|
-
_RTMdegrade: {
|
|
157
|
-
_originRtmUrl: url,
|
|
158
|
-
_isRTMSupported: RTMSupported,
|
|
159
|
-
_isRTMSupportCodec: RTMSupportCodec
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
plugins: backupCdn ? [backupCdn] : []
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return {
|
|
167
|
-
options: {
|
|
168
|
-
...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
|
|
169
|
-
url: enableRTMAutoTranscode ? util$6.appendSearchParams(url, { enableRTMAutoTranscode: "true" }) : void 0,
|
|
170
|
-
_RTMdegrade: void 0,
|
|
171
|
-
rts: {
|
|
172
|
-
retryCount: 0,
|
|
173
|
-
...ret,
|
|
174
|
-
backupURL: actualFallbackUrl,
|
|
175
|
-
backupConstruct: backupCdn
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
plugins: rtmCdn ? [rtmCdn] : []
|
|
179
|
-
};
|
|
180
|
-
};
|
|
181
|
-
const Sniffer$3 = window["VePlayer"].Sniffer;
|
|
182
|
-
var DrmType = /* @__PURE__ */ ((DrmType2) => {
|
|
183
|
-
DrmType2["Fairplay"] = "fairplay";
|
|
184
|
-
return DrmType2;
|
|
185
|
-
})(DrmType || {});
|
|
186
|
-
function getDrmType(drm) {
|
|
187
|
-
if ((drm == null ? void 0 : drm.fairplay) && (Sniffer$3.browser === "safari" || Sniffer$3.os.isIos)) {
|
|
188
|
-
return "fairplay";
|
|
189
|
-
}
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
function isMseSupportedWithDrm({
|
|
193
|
-
drm,
|
|
194
|
-
streamType
|
|
195
|
-
}) {
|
|
196
|
-
const drmType = getDrmType(drm);
|
|
197
|
-
if (!drmType) {
|
|
198
|
-
return true;
|
|
199
|
-
}
|
|
200
|
-
if (drmType === "fairplay" && streamType === "hls") {
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
return true;
|
|
204
|
-
}
|
|
205
|
-
const Sniffer$2 = window["VePlayer"].Sniffer;
|
|
206
|
-
const Codec$2 = window["VePlayer"].Codec;
|
|
207
|
-
const util$5 = window["VePlayer"].util;
|
|
208
|
-
const { isMMSSupported: isMMSSupported$1, isMseSupported: isMseSupported$1 } = util$5;
|
|
209
|
-
function enableMMS() {
|
|
210
|
-
return Sniffer$2.os.isIos;
|
|
211
|
-
}
|
|
212
|
-
function isFLVSupported(codec = Codec$2.H264) {
|
|
213
|
-
const isMediaSourceSupported = enableMMS() ? isMMSSupported$1 : isMseSupported$1;
|
|
214
|
-
return isMediaSourceSupported(codec);
|
|
215
|
-
}
|
|
216
|
-
const strategy$1 = window["VePlayer"].strategy;
|
|
217
|
-
const load$3 = window["VePlayer"].load;
|
|
218
|
-
const Codec$1 = window["VePlayer"].Codec;
|
|
219
|
-
const util$4 = window["VePlayer"].util;
|
|
220
|
-
const { appendSearchParams } = util$4;
|
|
221
|
-
const getFlvStrategy = async (options) => {
|
|
222
|
-
var _a, _b, _c, _d, _e, _f;
|
|
223
|
-
let mseStrategy;
|
|
224
|
-
let softStrategy;
|
|
225
|
-
const enableLowLatency = (_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.enableLowLatency;
|
|
226
|
-
const enableFrameChasing = ((_c = (_b = options == null ? void 0 : options.flv) == null ? void 0 : _b.lowLatency) == null ? void 0 : _c.enableFrameChasing) ?? true;
|
|
227
|
-
const abrPts = ((_e = (_d = options == null ? void 0 : options.flv) == null ? void 0 : _d.lowLatency) == null ? void 0 : _e.abrPts) ?? "-800";
|
|
228
|
-
const codec = await strategy$1.getCodec(options);
|
|
229
|
-
const isSoftDecode = await strategy$1.isSoftDecode(options, codec);
|
|
230
|
-
if (isSoftDecode) {
|
|
231
|
-
softStrategy = codec === Codec$1.H265 ? strategy$1.createSoftDecodeH265Strategy() : strategy$1.createSoftDecodeH264Strategy();
|
|
232
|
-
mseStrategy = strategy$1.createFlvMseStrategy(options);
|
|
233
|
-
}
|
|
234
|
-
if (codec === "unknown" ? isFLVSupported(Codec$1.H264) : isFLVSupported(codec)) {
|
|
235
|
-
mseStrategy = enableMMS() ? strategy$1.createFlvMssStrategy(options) : strategy$1.createFlvMseStrategy(options);
|
|
236
|
-
}
|
|
237
|
-
if (!mseStrategy && !softStrategy) {
|
|
238
|
-
return {};
|
|
239
|
-
}
|
|
240
|
-
const [mseModule, softModule] = await Promise.all([
|
|
241
|
-
(mseStrategy == null ? void 0 : mseStrategy.module) && load$3(mseStrategy.module).catch(() => void 0),
|
|
242
|
-
(softStrategy == null ? void 0 : softStrategy.module) && load$3(softStrategy.module).catch(() => void 0)
|
|
243
|
-
]);
|
|
244
|
-
(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));
|
|
245
|
-
const combineOptions = strategy$1.combineOptions([mseStrategy, softStrategy]);
|
|
246
|
-
const plugins = [];
|
|
247
|
-
if (enableLowLatency) {
|
|
248
|
-
combineOptions.url = appendSearchParams(options.url, { abr_pts: abrPts });
|
|
249
|
-
}
|
|
250
|
-
if (mseModule) {
|
|
251
|
-
plugins.push(mseModule.FlvPlugin);
|
|
252
|
-
if (enableLowLatency && enableFrameChasing) {
|
|
253
|
-
plugins.push(mseModule.Adaptive);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
return {
|
|
257
|
-
options: combineOptions,
|
|
258
|
-
plugins
|
|
259
|
-
};
|
|
260
|
-
};
|
|
261
|
-
const util$3 = window["VePlayer"].util;
|
|
262
|
-
const strategy = window["VePlayer"].strategy;
|
|
263
|
-
const getTypeStrategy = async (options, player, i18n) => {
|
|
264
|
-
const type = options.url ? util$3.getStreamType(options.url) : "";
|
|
265
|
-
if (!type || type === "unknown") {
|
|
266
|
-
return { options: {}, plugins: [] };
|
|
267
|
-
}
|
|
268
|
-
if (type === "rtm") {
|
|
269
|
-
return await getRtmStrategy(options, player, i18n);
|
|
270
|
-
}
|
|
271
|
-
if (type === "flv") {
|
|
272
|
-
return await getFlvStrategy(options);
|
|
273
|
-
}
|
|
274
|
-
if (type === "hls") {
|
|
275
|
-
if (!isMseSupportedWithDrm({ drm: options.drm, streamType: type })) {
|
|
276
|
-
return { options: {}, plugins: [] };
|
|
277
|
-
}
|
|
278
|
-
return await strategy.getHlsStrategy(options);
|
|
279
|
-
}
|
|
280
|
-
return { options: {}, plugins: [] };
|
|
281
|
-
};
|
|
282
53
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
283
54
|
function getDefaultExportFromCjs(x2) {
|
|
284
55
|
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
|
|
@@ -424,7 +195,7 @@ function RefreshIcon() {
|
|
|
424
195
|
}
|
|
425
196
|
var refresh = "";
|
|
426
197
|
const Plugin$3 = window["VePlayer"].Plugin;
|
|
427
|
-
const Sniffer$
|
|
198
|
+
const Sniffer$5 = window["VePlayer"].Sniffer;
|
|
428
199
|
const XGEvents = window["VePlayer"].XGEvents;
|
|
429
200
|
const { POSITIONS: POSITIONS$1 } = Plugin$3;
|
|
430
201
|
class Refresh extends Plugin$3 {
|
|
@@ -488,7 +259,7 @@ class Refresh extends Plugin$3 {
|
|
|
488
259
|
}
|
|
489
260
|
_initEvents() {
|
|
490
261
|
this._handleRefresh = debounce$1(this._handleRefresh.bind(this), 200);
|
|
491
|
-
const event2 = Sniffer$
|
|
262
|
+
const event2 = Sniffer$5.device === "mobile" ? "touchend" : "click";
|
|
492
263
|
this.bind(event2, this._handleRefresh);
|
|
493
264
|
this.show();
|
|
494
265
|
}
|
|
@@ -2969,7 +2740,7 @@ function v4(options, buf, offset) {
|
|
|
2969
2740
|
}
|
|
2970
2741
|
return unsafeStringify(rnds);
|
|
2971
2742
|
}
|
|
2972
|
-
const util$
|
|
2743
|
+
const util$7 = window["VePlayer"].util;
|
|
2973
2744
|
const DEVICE_ID_KEY = "veplayer_live_device_id";
|
|
2974
2745
|
const USER_ID_Key = "veplayer_live_user_id";
|
|
2975
2746
|
const genRandomID2 = (length) => {
|
|
@@ -2996,12 +2767,12 @@ const getUserId2 = () => {
|
|
|
2996
2767
|
return userId;
|
|
2997
2768
|
};
|
|
2998
2769
|
const generateUrlWithSessionId = (url) => {
|
|
2999
|
-
const urlObject = util$
|
|
2770
|
+
const urlObject = util$7.getUrlObject(url);
|
|
3000
2771
|
if (!urlObject) {
|
|
3001
2772
|
return url ?? "";
|
|
3002
2773
|
}
|
|
3003
2774
|
if (!(urlObject == null ? void 0 : urlObject.searchParams.get("_session_id"))) {
|
|
3004
|
-
return util$
|
|
2775
|
+
return util$7.appendSearchParams(url, { _session_id: generateSessionId() });
|
|
3005
2776
|
}
|
|
3006
2777
|
return url;
|
|
3007
2778
|
};
|
|
@@ -3101,7 +2872,7 @@ class Logger extends Plugin$2 {
|
|
|
3101
2872
|
device_id: this._deviceId,
|
|
3102
2873
|
error_report_stop: true,
|
|
3103
2874
|
ext: {
|
|
3104
|
-
veplayer_version: "2.3.
|
|
2875
|
+
veplayer_version: "2.3.1-rc.1",
|
|
3105
2876
|
flv_version: "3.0.21-rc.21",
|
|
3106
2877
|
hls_version: "3.0.21-rc.21",
|
|
3107
2878
|
rts_version: "0.2.1-alpha.14"
|
|
@@ -3186,7 +2957,7 @@ function getSoftDecodeRow(data) {
|
|
|
3186
2957
|
};
|
|
3187
2958
|
}
|
|
3188
2959
|
var infoPanel = "";
|
|
3189
|
-
const util$
|
|
2960
|
+
const util$6 = window["VePlayer"].util;
|
|
3190
2961
|
const Plugin$1 = window["VePlayer"].Plugin;
|
|
3191
2962
|
const XGUtil = window["VePlayer"].XGUtil;
|
|
3192
2963
|
class InfoPanel extends Plugin$1 {
|
|
@@ -3206,7 +2977,7 @@ class InfoPanel extends Plugin$1 {
|
|
|
3206
2977
|
};
|
|
3207
2978
|
}
|
|
3208
2979
|
get _streamType() {
|
|
3209
|
-
return util$
|
|
2980
|
+
return util$6.getStreamType(this.player.config.url);
|
|
3210
2981
|
}
|
|
3211
2982
|
afterCreate() {
|
|
3212
2983
|
this._playPlugin = this.player.plugins[this._streamType];
|
|
@@ -3381,39 +3152,6 @@ const ZH_CN$1 = {
|
|
|
3381
3152
|
DECODE_INFO: "软解信息",
|
|
3382
3153
|
REFRESH: "刷新"
|
|
3383
3154
|
};
|
|
3384
|
-
const DynamicModule$2 = window["VePlayer"].DynamicModule;
|
|
3385
|
-
const load$2 = window["VePlayer"].load;
|
|
3386
|
-
const getDrmStrategy = async (options, player) => {
|
|
3387
|
-
var _a;
|
|
3388
|
-
const drmType = getDrmType(options.drm);
|
|
3389
|
-
if (options.url && drmType === DrmType.Fairplay) {
|
|
3390
|
-
try {
|
|
3391
|
-
const { getDrmConfig, ...originFairplayConfig } = ((_a = options == null ? void 0 : options.drm) == null ? void 0 : _a.fairplay) ?? {};
|
|
3392
|
-
const [drmPlugin, drmConfig] = await Promise.all([
|
|
3393
|
-
load$2(DynamicModule$2.PluginDrm).then((module) => module.DrmPlugin).catch(() => void 0),
|
|
3394
|
-
getDrmConfig == null ? void 0 : getDrmConfig({
|
|
3395
|
-
url: options.url
|
|
3396
|
-
})
|
|
3397
|
-
]);
|
|
3398
|
-
const fairplayDrmConfig = Object.assign(
|
|
3399
|
-
{},
|
|
3400
|
-
originFairplayConfig,
|
|
3401
|
-
options == null ? void 0 : options.drm,
|
|
3402
|
-
drmConfig
|
|
3403
|
-
);
|
|
3404
|
-
drmConfig && (player == null ? void 0 : player.updateDrmConfig(drmConfig));
|
|
3405
|
-
return {
|
|
3406
|
-
options: {
|
|
3407
|
-
drm: fairplayDrmConfig
|
|
3408
|
-
},
|
|
3409
|
-
plugins: drmPlugin ? [drmPlugin] : []
|
|
3410
|
-
};
|
|
3411
|
-
} catch (error2) {
|
|
3412
|
-
console.log(error2);
|
|
3413
|
-
}
|
|
3414
|
-
}
|
|
3415
|
-
return {};
|
|
3416
|
-
};
|
|
3417
3155
|
var FUNC_ERROR_TEXT = "Expected a function";
|
|
3418
3156
|
var PLACEHOLDER = "__lodash_placeholder__";
|
|
3419
3157
|
var BIND_FLAG = 1, BIND_KEY_FLAG = 2, CURRY_BOUND_FLAG = 4, CURRY_FLAG = 8, CURRY_RIGHT_FLAG = 16, PARTIAL_FLAG = 32, PARTIAL_RIGHT_FLAG = 64, ARY_FLAG = 128, REARG_FLAG = 256, FLIP_FLAG = 512;
|
|
@@ -3903,6 +3641,20 @@ function identity(value) {
|
|
|
3903
3641
|
curry.placeholder = {};
|
|
3904
3642
|
var lodash_curry = curry;
|
|
3905
3643
|
var curry$1 = /* @__PURE__ */ getDefaultExportFromCjs(lodash_curry);
|
|
3644
|
+
const getUrlObject = (url) => {
|
|
3645
|
+
if (!url) {
|
|
3646
|
+
return;
|
|
3647
|
+
}
|
|
3648
|
+
const withoutProtocol = url.startsWith("//");
|
|
3649
|
+
if (withoutProtocol) {
|
|
3650
|
+
url = location.protocol + url;
|
|
3651
|
+
}
|
|
3652
|
+
try {
|
|
3653
|
+
return new URL(url);
|
|
3654
|
+
} catch (error2) {
|
|
3655
|
+
return;
|
|
3656
|
+
}
|
|
3657
|
+
};
|
|
3906
3658
|
const isType = curry$1(function(suffix, url) {
|
|
3907
3659
|
return url == null ? void 0 : url.split("?")[0].toLowerCase().includes(suffix);
|
|
3908
3660
|
});
|
|
@@ -3929,31 +3681,916 @@ function getStreamType(url) {
|
|
|
3929
3681
|
}
|
|
3930
3682
|
return "unknown";
|
|
3931
3683
|
}
|
|
3932
|
-
const
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
return {};
|
|
3939
|
-
}
|
|
3940
|
-
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;
|
|
3941
|
-
if (!abrOptions) {
|
|
3942
|
-
return {};
|
|
3943
|
-
}
|
|
3944
|
-
const abrPlugin = await load$1(DynamicModule$1.PluginAbr).catch(() => void 0);
|
|
3945
|
-
return {
|
|
3946
|
-
options: {
|
|
3947
|
-
[streamType === "flv" ? "abr" : "hlsabr"]: {
|
|
3948
|
-
...abrOptions,
|
|
3949
|
-
open: abrOptions.enable ?? true
|
|
3950
|
-
}
|
|
3951
|
-
},
|
|
3952
|
-
plugins: [
|
|
3953
|
-
streamType === "flv" ? abrPlugin == null ? void 0 : abrPlugin.AbrPlugin : abrPlugin == null ? void 0 : abrPlugin.HlsAbrPlugin
|
|
3954
|
-
]
|
|
3955
|
-
};
|
|
3684
|
+
const LiveUrlType = {
|
|
3685
|
+
Hls: "hls",
|
|
3686
|
+
LLHls: "ll-hls",
|
|
3687
|
+
Flv: "flv",
|
|
3688
|
+
Rtm: "rtm",
|
|
3689
|
+
LLFlv: "ll-flv"
|
|
3956
3690
|
};
|
|
3691
|
+
const Sniffer$4 = window["VePlayer"].Sniffer;
|
|
3692
|
+
const Codec$4 = window["VePlayer"].Codec;
|
|
3693
|
+
const util$5 = window["VePlayer"].util;
|
|
3694
|
+
const { isMMSSupported: isMMSSupported$1, isMseSupported: isMseSupported$2 } = util$5;
|
|
3695
|
+
function enableMMS() {
|
|
3696
|
+
return Sniffer$4.os.isIos;
|
|
3697
|
+
}
|
|
3698
|
+
function isFLVSupported(codec = Codec$4.H264) {
|
|
3699
|
+
const isMediaSourceSupported = enableMMS() ? isMMSSupported$1 : isMseSupported$2;
|
|
3700
|
+
return isMediaSourceSupported(codec);
|
|
3701
|
+
}
|
|
3702
|
+
var FallbackKind = /* @__PURE__ */ ((FallbackKind2) => {
|
|
3703
|
+
FallbackKind2["Error"] = "Error";
|
|
3704
|
+
FallbackKind2["Stall"] = "Stall";
|
|
3705
|
+
return FallbackKind2;
|
|
3706
|
+
})(FallbackKind || {});
|
|
3707
|
+
class BaseProtocol {
|
|
3708
|
+
constructor(options) {
|
|
3709
|
+
// 下一个 protocol 类
|
|
3710
|
+
__publicField(this, "nextProtocol");
|
|
3711
|
+
__publicField(this, "preProtocol");
|
|
3712
|
+
__publicField(this, "protocolStrategy");
|
|
3713
|
+
__publicField(this, "_fallback");
|
|
3714
|
+
this._fallback = options.fallback;
|
|
3715
|
+
}
|
|
3716
|
+
_getKindFallbackStrategy(kind) {
|
|
3717
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3718
|
+
return ((_c = (_b = (_a = this._fallback) == null ? void 0 : _a.fallbackStrategy) == null ? void 0 : _b[this.protocolType]) == null ? void 0 : _c[kind]) ?? ((_f = (_e = (_d = this._fallback) == null ? void 0 : _d.fallbackStrategy) == null ? void 0 : _e["all"]) == null ? void 0 : _f[kind]) ?? ((_g = this.defaultFallbackStrategy) == null ? void 0 : _g[kind]);
|
|
3719
|
+
}
|
|
3720
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
3721
|
+
get errorFallbackStrategy() {
|
|
3722
|
+
return this._getKindFallbackStrategy(
|
|
3723
|
+
"Error"
|
|
3724
|
+
/* Error */
|
|
3725
|
+
);
|
|
3726
|
+
}
|
|
3727
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
3728
|
+
get stallFallbackStrategy() {
|
|
3729
|
+
return this._getKindFallbackStrategy(
|
|
3730
|
+
"Stall"
|
|
3731
|
+
/* Stall */
|
|
3732
|
+
);
|
|
3733
|
+
}
|
|
3734
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
3735
|
+
shouldFallbackWhenError(params) {
|
|
3736
|
+
var _a, _b, _c;
|
|
3737
|
+
if ((_a = this.errorFallbackStrategy) == null ? void 0 : _a.shouldFallback) {
|
|
3738
|
+
return (_b = this.errorFallbackStrategy) == null ? void 0 : _b.shouldFallback(
|
|
3739
|
+
this.protocolType,
|
|
3740
|
+
params
|
|
3741
|
+
);
|
|
3742
|
+
}
|
|
3743
|
+
if ((_c = this.errorFallbackStrategy) == null ? void 0 : _c.excludeList) {
|
|
3744
|
+
return !this.errorFallbackStrategy.excludeList.includes(
|
|
3745
|
+
params.error.errorCode
|
|
3746
|
+
);
|
|
3747
|
+
}
|
|
3748
|
+
return false;
|
|
3749
|
+
}
|
|
3750
|
+
}
|
|
3751
|
+
const strategy$2 = window["VePlayer"].strategy;
|
|
3752
|
+
const load$7 = window["VePlayer"].load;
|
|
3753
|
+
const Codec$3 = window["VePlayer"].Codec;
|
|
3754
|
+
const util$4 = window["VePlayer"].util;
|
|
3755
|
+
const { appendSearchParams } = util$4;
|
|
3756
|
+
const getFlvStrategy = async (options) => {
|
|
3757
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3758
|
+
let mseStrategy;
|
|
3759
|
+
let softStrategy;
|
|
3760
|
+
const enableLowLatency = (_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.enableLowLatency;
|
|
3761
|
+
const enableFrameChasing = ((_c = (_b = options == null ? void 0 : options.flv) == null ? void 0 : _b.lowLatency) == null ? void 0 : _c.enableFrameChasing) ?? true;
|
|
3762
|
+
const abrPts = ((_e = (_d = options == null ? void 0 : options.flv) == null ? void 0 : _d.lowLatency) == null ? void 0 : _e.abrPts) ?? "-800";
|
|
3763
|
+
const codec = await strategy$2.getCodec(options);
|
|
3764
|
+
const isSoftDecode = await strategy$2.isSoftDecode(options, codec);
|
|
3765
|
+
if (isSoftDecode) {
|
|
3766
|
+
softStrategy = codec === Codec$3.H265 ? strategy$2.createSoftDecodeH265Strategy() : strategy$2.createSoftDecodeH264Strategy();
|
|
3767
|
+
mseStrategy = strategy$2.createFlvMseStrategy(options);
|
|
3768
|
+
}
|
|
3769
|
+
if (codec === "unknown" ? isFLVSupported(Codec$3.H264) : isFLVSupported(codec)) {
|
|
3770
|
+
mseStrategy = enableMMS() ? strategy$2.createFlvMssStrategy(options) : strategy$2.createFlvMseStrategy(options);
|
|
3771
|
+
}
|
|
3772
|
+
if (!mseStrategy && !softStrategy) {
|
|
3773
|
+
return {};
|
|
3774
|
+
}
|
|
3775
|
+
const [mseModule, softModule] = await Promise.all([
|
|
3776
|
+
(mseStrategy == null ? void 0 : mseStrategy.module) && load$7(mseStrategy.module).catch(() => void 0),
|
|
3777
|
+
(softStrategy == null ? void 0 : softStrategy.module) && load$7(softStrategy.module).catch(() => void 0)
|
|
3778
|
+
]);
|
|
3779
|
+
(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));
|
|
3780
|
+
const combineOptions = strategy$2.combineOptions([mseStrategy, softStrategy]);
|
|
3781
|
+
const plugins = [];
|
|
3782
|
+
if (enableLowLatency) {
|
|
3783
|
+
combineOptions.url = appendSearchParams(options.url, { abr_pts: abrPts });
|
|
3784
|
+
}
|
|
3785
|
+
if (mseModule) {
|
|
3786
|
+
plugins.push(mseModule.FlvPlugin);
|
|
3787
|
+
if (enableLowLatency && enableFrameChasing) {
|
|
3788
|
+
plugins.push(mseModule.Adaptive);
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
return {
|
|
3792
|
+
options: combineOptions,
|
|
3793
|
+
plugins
|
|
3794
|
+
};
|
|
3795
|
+
};
|
|
3796
|
+
const DynamicModule$5 = window["VePlayer"].DynamicModule;
|
|
3797
|
+
const load$6 = window["VePlayer"].load;
|
|
3798
|
+
class FlvProtocol extends BaseProtocol {
|
|
3799
|
+
static get suffix() {
|
|
3800
|
+
return ".flv";
|
|
3801
|
+
}
|
|
3802
|
+
get protocolType() {
|
|
3803
|
+
return LiveUrlType.Flv;
|
|
3804
|
+
}
|
|
3805
|
+
get defaultFallbackStrategy() {
|
|
3806
|
+
return {};
|
|
3807
|
+
}
|
|
3808
|
+
static generateUrl(urls, {
|
|
3809
|
+
generateUrlFromOtherProtocol: generateUrlFromOtherProtocol2
|
|
3810
|
+
}) {
|
|
3811
|
+
return urls[LiveUrlType.Flv] ?? generateUrlFromOtherProtocol2();
|
|
3812
|
+
}
|
|
3813
|
+
static canGenerateOtherProtocol() {
|
|
3814
|
+
return true;
|
|
3815
|
+
}
|
|
3816
|
+
async canPlay() {
|
|
3817
|
+
return {
|
|
3818
|
+
canPlay: isFLVSupported()
|
|
3819
|
+
};
|
|
3820
|
+
}
|
|
3821
|
+
shouldFallbackWhenStall() {
|
|
3822
|
+
return false;
|
|
3823
|
+
}
|
|
3824
|
+
async getProtocolStrategy(options, {
|
|
3825
|
+
enableSelector
|
|
3826
|
+
}) {
|
|
3827
|
+
return getFlvStrategy(
|
|
3828
|
+
enableSelector ? {
|
|
3829
|
+
...options,
|
|
3830
|
+
flv: {
|
|
3831
|
+
...options.flv,
|
|
3832
|
+
enableLowLatency: false
|
|
3833
|
+
}
|
|
3834
|
+
} : options
|
|
3835
|
+
);
|
|
3836
|
+
}
|
|
3837
|
+
async getAbrStrategy(options) {
|
|
3838
|
+
var _a;
|
|
3839
|
+
const abrOptions = (_a = options == null ? void 0 : options.flv) == null ? void 0 : _a.abr;
|
|
3840
|
+
if (!abrOptions) {
|
|
3841
|
+
return {};
|
|
3842
|
+
}
|
|
3843
|
+
const abrPlugin = await load$6(DynamicModule$5.PluginAbr).catch(
|
|
3844
|
+
() => void 0
|
|
3845
|
+
);
|
|
3846
|
+
return {
|
|
3847
|
+
options: {
|
|
3848
|
+
abr: {
|
|
3849
|
+
...abrOptions,
|
|
3850
|
+
open: abrOptions.enable ?? true
|
|
3851
|
+
}
|
|
3852
|
+
},
|
|
3853
|
+
plugins: [abrPlugin == null ? void 0 : abrPlugin.AbrPlugin]
|
|
3854
|
+
};
|
|
3855
|
+
}
|
|
3856
|
+
getDrmStrategy() {
|
|
3857
|
+
return void 0;
|
|
3858
|
+
}
|
|
3859
|
+
}
|
|
3860
|
+
class FlvLowLatencyProtocol extends FlvProtocol {
|
|
3861
|
+
get protocolType() {
|
|
3862
|
+
return LiveUrlType.LLFlv;
|
|
3863
|
+
}
|
|
3864
|
+
async getProtocolStrategy(options) {
|
|
3865
|
+
return getFlvStrategy({
|
|
3866
|
+
...options,
|
|
3867
|
+
flv: {
|
|
3868
|
+
...options.flv,
|
|
3869
|
+
enableLowLatency: true
|
|
3870
|
+
}
|
|
3871
|
+
});
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
const Sniffer$3 = window["VePlayer"].Sniffer;
|
|
3875
|
+
var DrmType = /* @__PURE__ */ ((DrmType2) => {
|
|
3876
|
+
DrmType2["Fairplay"] = "fairplay";
|
|
3877
|
+
return DrmType2;
|
|
3878
|
+
})(DrmType || {});
|
|
3879
|
+
function getDrmType(drm) {
|
|
3880
|
+
if ((drm == null ? void 0 : drm.fairplay) && (Sniffer$3.browser === "safari" || Sniffer$3.os.isIos)) {
|
|
3881
|
+
return "fairplay";
|
|
3882
|
+
}
|
|
3883
|
+
return;
|
|
3884
|
+
}
|
|
3885
|
+
function isMseSupportedWithDrm({
|
|
3886
|
+
drm,
|
|
3887
|
+
streamType
|
|
3888
|
+
}) {
|
|
3889
|
+
const drmType = getDrmType(drm);
|
|
3890
|
+
if (!drmType) {
|
|
3891
|
+
return true;
|
|
3892
|
+
}
|
|
3893
|
+
if (drmType === "fairplay" && streamType === "hls") {
|
|
3894
|
+
return false;
|
|
3895
|
+
}
|
|
3896
|
+
return true;
|
|
3897
|
+
}
|
|
3898
|
+
const Codec$2 = window["VePlayer"].Codec;
|
|
3899
|
+
const strategy$1 = window["VePlayer"].strategy;
|
|
3900
|
+
const load$5 = window["VePlayer"].load;
|
|
3901
|
+
const Sniffer$2 = window["VePlayer"].Sniffer;
|
|
3902
|
+
const util$3 = window["VePlayer"].util;
|
|
3903
|
+
const { isMseSupported: isMseSupported$1 } = util$3;
|
|
3904
|
+
function enableHlsJs(options) {
|
|
3905
|
+
var _a, _b;
|
|
3906
|
+
if ((_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.enableHlsJs) {
|
|
3907
|
+
return true;
|
|
3908
|
+
}
|
|
3909
|
+
if (((_b = options == null ? void 0 : options.ad) == null ? void 0 : _b.adType) === "ssai") {
|
|
3910
|
+
return true;
|
|
3911
|
+
}
|
|
3912
|
+
return false;
|
|
3913
|
+
}
|
|
3914
|
+
const getHlsStrategy = async (options) => {
|
|
3915
|
+
var _a, _b;
|
|
3916
|
+
let mseStrategy;
|
|
3917
|
+
let softStrategy;
|
|
3918
|
+
if (!isMseSupportedWithDrm({ drm: options.drm, streamType: "hls" })) {
|
|
3919
|
+
return { options: {}, plugins: [] };
|
|
3920
|
+
}
|
|
3921
|
+
const codec = await strategy$1.getCodec(options);
|
|
3922
|
+
const isSoftDecode = await strategy$1.isSoftDecode(options, codec);
|
|
3923
|
+
const useHlsJs = enableHlsJs(options);
|
|
3924
|
+
if (isSoftDecode) {
|
|
3925
|
+
softStrategy = codec === Codec$2.H265 ? strategy$1.createSoftDecodeH265Strategy() : strategy$1.createSoftDecodeH264Strategy();
|
|
3926
|
+
mseStrategy = strategy$1.createHlsMseStrategy(options, useHlsJs);
|
|
3927
|
+
}
|
|
3928
|
+
if ((Sniffer$2.device !== "mobile" || ((_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.enableMSE)) && (codec === "unknown" ? isMseSupported$1(Codec$2.H264) : isMseSupported$1(codec))) {
|
|
3929
|
+
mseStrategy = strategy$1.createHlsMseStrategy(options, useHlsJs);
|
|
3930
|
+
}
|
|
3931
|
+
if (!mseStrategy && !softStrategy) {
|
|
3932
|
+
return {};
|
|
3933
|
+
}
|
|
3934
|
+
const [mseModule, softModule] = await Promise.all([
|
|
3935
|
+
(mseStrategy == null ? void 0 : mseStrategy.module) && load$5(mseStrategy.module).catch(() => void 0),
|
|
3936
|
+
(softStrategy == null ? void 0 : softStrategy.module) && load$5(softStrategy.module).catch(() => void 0)
|
|
3937
|
+
]);
|
|
3938
|
+
(softModule == null ? void 0 : softModule.XGVideoPlugin) && ((_b = softStrategy == null ? void 0 : softStrategy.afterLoad) == null ? void 0 : _b.call(softStrategy, softModule == null ? void 0 : softModule.XGVideoPlugin));
|
|
3939
|
+
const combineOptions = strategy$1.combineOptions([mseStrategy, softStrategy]);
|
|
3940
|
+
return {
|
|
3941
|
+
options: combineOptions,
|
|
3942
|
+
plugins: (mseModule == null ? void 0 : mseModule.HlsPlugin) ? [mseModule.HlsPlugin] : []
|
|
3943
|
+
};
|
|
3944
|
+
};
|
|
3945
|
+
function getType(definition) {
|
|
3946
|
+
if (typeof definition === "string") {
|
|
3947
|
+
return getStreamType(definition);
|
|
3948
|
+
}
|
|
3949
|
+
if (definition.type) {
|
|
3950
|
+
return definition.type;
|
|
3951
|
+
}
|
|
3952
|
+
return getStreamType(definition.url);
|
|
3953
|
+
}
|
|
3954
|
+
function pushToEmpty(obj, key, value) {
|
|
3955
|
+
if (!obj[key]) {
|
|
3956
|
+
obj[key] = [];
|
|
3957
|
+
}
|
|
3958
|
+
obj[key].push(value);
|
|
3959
|
+
}
|
|
3960
|
+
function splitPlaylist(playlist) {
|
|
3961
|
+
return playlist.reduce((pre, source) => {
|
|
3962
|
+
const definitionMap = source.definitions.reduce(
|
|
3963
|
+
(preDefinition, definition) => {
|
|
3964
|
+
const type = getType(definition);
|
|
3965
|
+
pushToEmpty(preDefinition, type, definition);
|
|
3966
|
+
return preDefinition;
|
|
3967
|
+
},
|
|
3968
|
+
{}
|
|
3969
|
+
);
|
|
3970
|
+
Object.keys(definitionMap).map((type) => {
|
|
3971
|
+
pushToEmpty(pre, type, {
|
|
3972
|
+
...source,
|
|
3973
|
+
definitions: definitionMap[type]
|
|
3974
|
+
});
|
|
3975
|
+
});
|
|
3976
|
+
return pre;
|
|
3977
|
+
}, {});
|
|
3978
|
+
}
|
|
3979
|
+
function generateUrlFromOtherProtocol(playlist, suffix, targetSuffix) {
|
|
3980
|
+
return modifyPlaylistUrl(playlist, (url) => {
|
|
3981
|
+
return url.replace(suffix, targetSuffix);
|
|
3982
|
+
});
|
|
3983
|
+
}
|
|
3984
|
+
function modifyPlaylistUrl(playlist, callback) {
|
|
3985
|
+
const newPlaylist = [];
|
|
3986
|
+
playlist == null ? void 0 : playlist.forEach((source) => {
|
|
3987
|
+
const definitions = [];
|
|
3988
|
+
source.definitions.forEach((definition) => {
|
|
3989
|
+
var _a;
|
|
3990
|
+
if (typeof definition === "string") {
|
|
3991
|
+
definitions.push(callback(definition));
|
|
3992
|
+
} else {
|
|
3993
|
+
definitions.push({
|
|
3994
|
+
...definition,
|
|
3995
|
+
url: callback(definition.url),
|
|
3996
|
+
fallbackUrls: (_a = definition.fallbackUrls) == null ? void 0 : _a.map(
|
|
3997
|
+
(fallbackUrl) => callback(fallbackUrl)
|
|
3998
|
+
)
|
|
3999
|
+
});
|
|
4000
|
+
}
|
|
4001
|
+
});
|
|
4002
|
+
newPlaylist.push({
|
|
4003
|
+
...source,
|
|
4004
|
+
definitions
|
|
4005
|
+
});
|
|
4006
|
+
});
|
|
4007
|
+
return newPlaylist;
|
|
4008
|
+
}
|
|
4009
|
+
const DynamicModule$4 = window["VePlayer"].DynamicModule;
|
|
4010
|
+
const load$4 = window["VePlayer"].load;
|
|
4011
|
+
const getDrmStrategy = async (options, player) => {
|
|
4012
|
+
var _a;
|
|
4013
|
+
const drmType = getDrmType(options.drm);
|
|
4014
|
+
if (options.url && drmType === DrmType.Fairplay) {
|
|
4015
|
+
try {
|
|
4016
|
+
const { getDrmConfig, ...originFairplayConfig } = ((_a = options == null ? void 0 : options.drm) == null ? void 0 : _a.fairplay) ?? {};
|
|
4017
|
+
const [drmPlugin, drmConfig] = await Promise.all([
|
|
4018
|
+
load$4(DynamicModule$4.PluginDrm).then((module) => module.DrmPlugin).catch(() => void 0),
|
|
4019
|
+
getDrmConfig == null ? void 0 : getDrmConfig({
|
|
4020
|
+
url: options.url
|
|
4021
|
+
})
|
|
4022
|
+
]);
|
|
4023
|
+
const fairplayDrmConfig = Object.assign(
|
|
4024
|
+
{},
|
|
4025
|
+
originFairplayConfig,
|
|
4026
|
+
options == null ? void 0 : options.drm,
|
|
4027
|
+
drmConfig
|
|
4028
|
+
);
|
|
4029
|
+
drmConfig && (player == null ? void 0 : player.updateDrmConfig(drmConfig));
|
|
4030
|
+
return {
|
|
4031
|
+
options: {
|
|
4032
|
+
drm: fairplayDrmConfig
|
|
4033
|
+
},
|
|
4034
|
+
plugins: drmPlugin ? [drmPlugin] : []
|
|
4035
|
+
};
|
|
4036
|
+
} catch (error2) {
|
|
4037
|
+
console.log(error2);
|
|
4038
|
+
}
|
|
4039
|
+
}
|
|
4040
|
+
return {};
|
|
4041
|
+
};
|
|
4042
|
+
const DynamicModule$3 = window["VePlayer"].DynamicModule;
|
|
4043
|
+
const load$3 = window["VePlayer"].load;
|
|
4044
|
+
const util$2 = window["VePlayer"].util;
|
|
4045
|
+
class HlsProtocol extends BaseProtocol {
|
|
4046
|
+
static get suffix() {
|
|
4047
|
+
return ".m3u8";
|
|
4048
|
+
}
|
|
4049
|
+
get protocolType() {
|
|
4050
|
+
return LiveUrlType.Hls;
|
|
4051
|
+
}
|
|
4052
|
+
get defaultFallbackStrategy() {
|
|
4053
|
+
return {};
|
|
4054
|
+
}
|
|
4055
|
+
static canGenerateOtherProtocol() {
|
|
4056
|
+
return true;
|
|
4057
|
+
}
|
|
4058
|
+
static generateUrl(urls, {
|
|
4059
|
+
generateUrlFromOtherProtocol: generateUrlFromOtherProtocol2
|
|
4060
|
+
}) {
|
|
4061
|
+
if (urls[LiveUrlType.Hls]) {
|
|
4062
|
+
return urls[LiveUrlType.Hls];
|
|
4063
|
+
}
|
|
4064
|
+
if (urls[LiveUrlType.LLHls]) {
|
|
4065
|
+
return modifyPlaylistUrl(urls[LiveUrlType.LLHls], (url) => {
|
|
4066
|
+
return util$2.appendSearchParams(url, {
|
|
4067
|
+
fpkey_normal_hls: "1"
|
|
4068
|
+
});
|
|
4069
|
+
});
|
|
4070
|
+
}
|
|
4071
|
+
return generateUrlFromOtherProtocol2();
|
|
4072
|
+
}
|
|
4073
|
+
async canPlay() {
|
|
4074
|
+
return { canPlay: true };
|
|
4075
|
+
}
|
|
4076
|
+
shouldFallbackWhenStall() {
|
|
4077
|
+
return false;
|
|
4078
|
+
}
|
|
4079
|
+
async getProtocolStrategy(options) {
|
|
4080
|
+
return getHlsStrategy(options);
|
|
4081
|
+
}
|
|
4082
|
+
async getAbrStrategy(options) {
|
|
4083
|
+
var _a;
|
|
4084
|
+
const abrOptions = (_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.abr;
|
|
4085
|
+
if (!abrOptions) {
|
|
4086
|
+
return {};
|
|
4087
|
+
}
|
|
4088
|
+
const abrPlugin = await load$3(DynamicModule$3.PluginAbr).catch(
|
|
4089
|
+
() => void 0
|
|
4090
|
+
);
|
|
4091
|
+
return {
|
|
4092
|
+
options: {
|
|
4093
|
+
hlsabr: {
|
|
4094
|
+
...abrOptions,
|
|
4095
|
+
open: abrOptions.enable ?? true
|
|
4096
|
+
}
|
|
4097
|
+
},
|
|
4098
|
+
plugins: [abrPlugin == null ? void 0 : abrPlugin.HlsAbrPlugin]
|
|
4099
|
+
};
|
|
4100
|
+
}
|
|
4101
|
+
getDrmStrategy(options, player) {
|
|
4102
|
+
return getDrmStrategy(options, player);
|
|
4103
|
+
}
|
|
4104
|
+
}
|
|
4105
|
+
class HlsLowLatencyProtocol extends BaseProtocol {
|
|
4106
|
+
static get suffix() {
|
|
4107
|
+
return ".m3u8";
|
|
4108
|
+
}
|
|
4109
|
+
get protocolType() {
|
|
4110
|
+
return LiveUrlType.LLHls;
|
|
4111
|
+
}
|
|
4112
|
+
get defaultFallbackStrategy() {
|
|
4113
|
+
return {};
|
|
4114
|
+
}
|
|
4115
|
+
static generateUrl(urls) {
|
|
4116
|
+
return urls[LiveUrlType.LLHls];
|
|
4117
|
+
}
|
|
4118
|
+
static canGenerateOtherProtocol() {
|
|
4119
|
+
return true;
|
|
4120
|
+
}
|
|
4121
|
+
async canPlay() {
|
|
4122
|
+
return { canPlay: true };
|
|
4123
|
+
}
|
|
4124
|
+
shouldFallbackWhenStall() {
|
|
4125
|
+
return false;
|
|
4126
|
+
}
|
|
4127
|
+
async getProtocolStrategy(options) {
|
|
4128
|
+
return getHlsStrategy(options);
|
|
4129
|
+
}
|
|
4130
|
+
getAbrStrategy() {
|
|
4131
|
+
return void 0;
|
|
4132
|
+
}
|
|
4133
|
+
getDrmStrategy() {
|
|
4134
|
+
return void 0;
|
|
4135
|
+
}
|
|
4136
|
+
}
|
|
4137
|
+
const DynamicModule$2 = window["VePlayer"].DynamicModule;
|
|
4138
|
+
const load$2 = window["VePlayer"].load;
|
|
4139
|
+
async function isRTMSupported() {
|
|
4140
|
+
const { RtmPlugin } = await load$2(DynamicModule$2.PluginRtm);
|
|
4141
|
+
return RtmPlugin.isSupported();
|
|
4142
|
+
}
|
|
4143
|
+
async function isRTMSupportCodec(codec = RTMCodec.H264) {
|
|
4144
|
+
const { RtmPlugin } = await load$2(DynamicModule$2.PluginRtm);
|
|
4145
|
+
if (codec === RTMCodec.H264)
|
|
4146
|
+
return RtmPlugin.isSupportedH264();
|
|
4147
|
+
return false;
|
|
4148
|
+
}
|
|
4149
|
+
const strategy = window["VePlayer"].strategy;
|
|
4150
|
+
const util$1 = window["VePlayer"].util;
|
|
4151
|
+
const DynamicModule$1 = window["VePlayer"].DynamicModule;
|
|
4152
|
+
const load$1 = window["VePlayer"].load;
|
|
4153
|
+
const Codec$1 = window["VePlayer"].Codec;
|
|
4154
|
+
const Sniffer$1 = window["VePlayer"].Sniffer;
|
|
4155
|
+
const rtmStrategy = {
|
|
4156
|
+
options: {},
|
|
4157
|
+
module: DynamicModule$1.PluginRtm
|
|
4158
|
+
};
|
|
4159
|
+
const generateFallbackUrl = (url) => {
|
|
4160
|
+
if (Sniffer$1.device === "pc") {
|
|
4161
|
+
return url.replace(".sdp", ".flv");
|
|
4162
|
+
} else {
|
|
4163
|
+
return url.replace(".sdp", ".m3u8");
|
|
4164
|
+
}
|
|
4165
|
+
};
|
|
4166
|
+
const getRtmStrategy = async (options, player, i18n) => {
|
|
4167
|
+
var _a, _b;
|
|
4168
|
+
let backupStrategy;
|
|
4169
|
+
let actualFallbackUrl = "";
|
|
4170
|
+
const { url, playlist } = options;
|
|
4171
|
+
const { fallbackUrl, enableRTMAutoTranscode, ...ret } = options.rtm || {};
|
|
4172
|
+
let { enableFallback = true } = options.rtm || {};
|
|
4173
|
+
if (playlist == null ? void 0 : playlist.length) {
|
|
4174
|
+
enableFallback = false;
|
|
4175
|
+
}
|
|
4176
|
+
const isRTMAutoTranscode = enableRTMAutoTranscode || ((_a = getUrlObject(url)) == null ? void 0 : _a.searchParams.get("enableRTMAutoTranscode")) === "true";
|
|
4177
|
+
if (enableFallback) {
|
|
4178
|
+
if (fallbackUrl) {
|
|
4179
|
+
actualFallbackUrl = fallbackUrl;
|
|
4180
|
+
} else if (isRTMAutoTranscode && url) {
|
|
4181
|
+
actualFallbackUrl = generateFallbackUrl(url);
|
|
4182
|
+
} else {
|
|
4183
|
+
console.warn(
|
|
4184
|
+
create(ErrorCode.EMPTY_RTM_FALLBACK_PARAMETER, i18n).message
|
|
4185
|
+
);
|
|
4186
|
+
}
|
|
4187
|
+
}
|
|
4188
|
+
const backupType = actualFallbackUrl && util$1.getStreamType(actualFallbackUrl);
|
|
4189
|
+
if (backupType === "flv" && util$1.isMseSupported(Codec$1.H264)) {
|
|
4190
|
+
backupStrategy = strategy.createFlvMseStrategy(options);
|
|
4191
|
+
} else if (backupType === "hls" && (Sniffer$1.device !== "mobile" || ((_b = options == null ? void 0 : options.hls) == null ? void 0 : _b.enableMSE)) && util$1.isMseSupported(Codec$1.H264)) {
|
|
4192
|
+
backupStrategy = strategy.createHlsMseStrategy(options);
|
|
4193
|
+
}
|
|
4194
|
+
const [rtmCdn, backupCdn] = await Promise.all([
|
|
4195
|
+
load$1(rtmStrategy.module).then((module) => {
|
|
4196
|
+
return module.RtmPlugin;
|
|
4197
|
+
}).catch(() => void 0),
|
|
4198
|
+
backupStrategy && load$1(backupStrategy.module).then((module) => {
|
|
4199
|
+
if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule$1.PluginFlv) {
|
|
4200
|
+
return module.FlvPlugin;
|
|
4201
|
+
} else if ((backupStrategy == null ? void 0 : backupStrategy.module) === DynamicModule$1.PluginHls) {
|
|
4202
|
+
return module.HlsPlugin;
|
|
4203
|
+
}
|
|
4204
|
+
}).catch(() => void 0)
|
|
4205
|
+
]);
|
|
4206
|
+
if (actualFallbackUrl) {
|
|
4207
|
+
const [RTMSupported, RTMSupportCodec] = await Promise.all([
|
|
4208
|
+
isRTMSupported(),
|
|
4209
|
+
isRTMSupportCodec()
|
|
4210
|
+
]);
|
|
4211
|
+
if (!RTMSupported || !RTMSupportCodec) {
|
|
4212
|
+
if (player) {
|
|
4213
|
+
player.emit("degrade", {
|
|
4214
|
+
url: actualFallbackUrl,
|
|
4215
|
+
originRtmUrl: url,
|
|
4216
|
+
code: "NOT_SUPPORT",
|
|
4217
|
+
message: "not support rtm or h264",
|
|
4218
|
+
isRTMSupported: RTMSupported,
|
|
4219
|
+
isRTMSupportCodec: RTMSupportCodec
|
|
4220
|
+
});
|
|
4221
|
+
}
|
|
4222
|
+
return {
|
|
4223
|
+
options: {
|
|
4224
|
+
...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
|
|
4225
|
+
url: actualFallbackUrl,
|
|
4226
|
+
_RTMdegrade: {
|
|
4227
|
+
_originRtmUrl: url,
|
|
4228
|
+
_isRTMSupported: RTMSupported,
|
|
4229
|
+
_isRTMSupportCodec: RTMSupportCodec
|
|
4230
|
+
}
|
|
4231
|
+
},
|
|
4232
|
+
plugins: backupCdn ? [backupCdn] : []
|
|
4233
|
+
};
|
|
4234
|
+
}
|
|
4235
|
+
}
|
|
4236
|
+
return {
|
|
4237
|
+
options: {
|
|
4238
|
+
...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
|
|
4239
|
+
url: enableRTMAutoTranscode ? util$1.appendSearchParams(url, { enableRTMAutoTranscode: "true" }) : void 0,
|
|
4240
|
+
_RTMdegrade: void 0,
|
|
4241
|
+
rts: {
|
|
4242
|
+
retryCount: 0,
|
|
4243
|
+
...ret,
|
|
4244
|
+
backupURL: actualFallbackUrl,
|
|
4245
|
+
backupConstruct: backupCdn
|
|
4246
|
+
}
|
|
4247
|
+
},
|
|
4248
|
+
plugins: rtmCdn ? [rtmCdn] : []
|
|
4249
|
+
};
|
|
4250
|
+
};
|
|
4251
|
+
class RtmProtocol extends BaseProtocol {
|
|
4252
|
+
static get suffix() {
|
|
4253
|
+
return ".sdp";
|
|
4254
|
+
}
|
|
4255
|
+
get protocolType() {
|
|
4256
|
+
return LiveUrlType.Rtm;
|
|
4257
|
+
}
|
|
4258
|
+
get defaultFallbackStrategy() {
|
|
4259
|
+
return { [FallbackKind.Error]: { shouldFallback: () => true } };
|
|
4260
|
+
}
|
|
4261
|
+
static canGenerateOtherProtocol(options) {
|
|
4262
|
+
var _a;
|
|
4263
|
+
return (_a = options.rtm) == null ? void 0 : _a.enableRTMAutoTranscode;
|
|
4264
|
+
}
|
|
4265
|
+
static generateUrl(urls, {
|
|
4266
|
+
generateUrlFromOtherProtocol: generateUrlFromOtherProtocol2,
|
|
4267
|
+
options
|
|
4268
|
+
}) {
|
|
4269
|
+
var _a;
|
|
4270
|
+
if (urls[LiveUrlType.Rtm]) {
|
|
4271
|
+
return urls[LiveUrlType.Rtm];
|
|
4272
|
+
}
|
|
4273
|
+
if ((_a = options.rtm) == null ? void 0 : _a.enableRTMAutoTranscode) {
|
|
4274
|
+
return generateUrlFromOtherProtocol2();
|
|
4275
|
+
}
|
|
4276
|
+
console.warn("生成 rtm 地址失败。请传入 rtm 播放地址,或开启自动转码");
|
|
4277
|
+
return;
|
|
4278
|
+
}
|
|
4279
|
+
async canPlay() {
|
|
4280
|
+
const [isSupported, isSupportCodec] = await Promise.all([
|
|
4281
|
+
isRTMSupported(),
|
|
4282
|
+
isRTMSupportCodec()
|
|
4283
|
+
]);
|
|
4284
|
+
return {
|
|
4285
|
+
canPlay: isSupported && isSupportCodec
|
|
4286
|
+
};
|
|
4287
|
+
}
|
|
4288
|
+
shouldFallbackWhenStall() {
|
|
4289
|
+
return false;
|
|
4290
|
+
}
|
|
4291
|
+
async getProtocolStrategy(options, {
|
|
4292
|
+
player,
|
|
4293
|
+
i18n,
|
|
4294
|
+
enableSelector
|
|
4295
|
+
}) {
|
|
4296
|
+
this.protocolStrategy = await getRtmStrategy(
|
|
4297
|
+
enableSelector ? {
|
|
4298
|
+
options,
|
|
4299
|
+
rtm: {
|
|
4300
|
+
...options.rtm,
|
|
4301
|
+
enableFallback: false
|
|
4302
|
+
}
|
|
4303
|
+
} : options,
|
|
4304
|
+
player,
|
|
4305
|
+
i18n
|
|
4306
|
+
);
|
|
4307
|
+
return this.protocolStrategy;
|
|
4308
|
+
}
|
|
4309
|
+
getAbrStrategy() {
|
|
4310
|
+
return void 0;
|
|
4311
|
+
}
|
|
4312
|
+
getDrmStrategy() {
|
|
4313
|
+
return void 0;
|
|
4314
|
+
}
|
|
4315
|
+
}
|
|
4316
|
+
class ProtocolSelector {
|
|
4317
|
+
constructor({ queue, streams, options }) {
|
|
4318
|
+
// 链开始的类
|
|
4319
|
+
// start?: AbstractProtocol;
|
|
4320
|
+
// 链结束的类,也是当前正在播放的类型
|
|
4321
|
+
__publicField(this, "current");
|
|
4322
|
+
// 降级顺序
|
|
4323
|
+
__publicField(this, "_queue");
|
|
4324
|
+
__publicField(this, "_streams");
|
|
4325
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4326
|
+
// @ts-ignore
|
|
4327
|
+
__publicField(this, "_options");
|
|
4328
|
+
this._queue = queue;
|
|
4329
|
+
this._streams = streams;
|
|
4330
|
+
this._options = options;
|
|
4331
|
+
this.current = this._getStartProtocol();
|
|
4332
|
+
}
|
|
4333
|
+
// 获取最终返回的播放类型和参数。
|
|
4334
|
+
async getProtocol() {
|
|
4335
|
+
if (!this.current) {
|
|
4336
|
+
return;
|
|
4337
|
+
}
|
|
4338
|
+
const { canPlay } = await this.current.canPlay() ?? {};
|
|
4339
|
+
if (canPlay) {
|
|
4340
|
+
return this.current;
|
|
4341
|
+
}
|
|
4342
|
+
this.next();
|
|
4343
|
+
return this.getProtocol();
|
|
4344
|
+
}
|
|
4345
|
+
// 降级时,将指针指到上次结束的位置
|
|
4346
|
+
next() {
|
|
4347
|
+
var _a;
|
|
4348
|
+
this.current = (_a = this.current) == null ? void 0 : _a.nextProtocol;
|
|
4349
|
+
}
|
|
4350
|
+
// 生成责任链
|
|
4351
|
+
_getStartProtocol() {
|
|
4352
|
+
let nextProtocol;
|
|
4353
|
+
for (let index = this._queue.length - 1; index >= 0; index--) {
|
|
4354
|
+
const type = this._queue[index];
|
|
4355
|
+
const protocol = this._streams[type];
|
|
4356
|
+
if (protocol) {
|
|
4357
|
+
if (nextProtocol) {
|
|
4358
|
+
nextProtocol.preProtocol = protocol;
|
|
4359
|
+
protocol.nextProtocol = nextProtocol;
|
|
4360
|
+
}
|
|
4361
|
+
nextProtocol = protocol;
|
|
4362
|
+
}
|
|
4363
|
+
}
|
|
4364
|
+
return nextProtocol;
|
|
4365
|
+
}
|
|
4366
|
+
}
|
|
4367
|
+
const _LowLatencySelector = class extends ProtocolSelector {
|
|
4368
|
+
// 目前默认传入了默认的低延迟选择顺序,
|
|
4369
|
+
// 也可以支持自定义配置
|
|
4370
|
+
constructor({
|
|
4371
|
+
streams,
|
|
4372
|
+
options
|
|
4373
|
+
}) {
|
|
4374
|
+
super({
|
|
4375
|
+
queue: _LowLatencySelector.queue,
|
|
4376
|
+
streams,
|
|
4377
|
+
options
|
|
4378
|
+
});
|
|
4379
|
+
}
|
|
4380
|
+
};
|
|
4381
|
+
let LowLatencySelector = _LowLatencySelector;
|
|
4382
|
+
__publicField(LowLatencySelector, "queue", [
|
|
4383
|
+
LiveUrlType.Rtm,
|
|
4384
|
+
LiveUrlType.LLFlv,
|
|
4385
|
+
LiveUrlType.Flv,
|
|
4386
|
+
LiveUrlType.LLHls,
|
|
4387
|
+
LiveUrlType.Hls
|
|
4388
|
+
]);
|
|
4389
|
+
class CustomSelector extends ProtocolSelector {
|
|
4390
|
+
constructor({
|
|
4391
|
+
streams,
|
|
4392
|
+
options
|
|
4393
|
+
}) {
|
|
4394
|
+
var _a;
|
|
4395
|
+
super({
|
|
4396
|
+
queue: (_a = options.fallback) == null ? void 0 : _a.fallbackOrder,
|
|
4397
|
+
streams,
|
|
4398
|
+
options
|
|
4399
|
+
});
|
|
4400
|
+
}
|
|
4401
|
+
}
|
|
4402
|
+
__publicField(CustomSelector, "queue");
|
|
4403
|
+
const _ProtocolManager = class {
|
|
4404
|
+
constructor(options) {
|
|
4405
|
+
__publicField(this, "_options");
|
|
4406
|
+
__publicField(this, "_selector");
|
|
4407
|
+
__publicField(this, "_protocol");
|
|
4408
|
+
__publicField(this, "_playlistMap", {});
|
|
4409
|
+
this._options = options;
|
|
4410
|
+
this._init({
|
|
4411
|
+
url: options.url,
|
|
4412
|
+
playlist: options.playlist
|
|
4413
|
+
});
|
|
4414
|
+
}
|
|
4415
|
+
get enableSelector() {
|
|
4416
|
+
return !!this._selector;
|
|
4417
|
+
}
|
|
4418
|
+
get protocol() {
|
|
4419
|
+
return this._protocol;
|
|
4420
|
+
}
|
|
4421
|
+
get playlist() {
|
|
4422
|
+
var _a;
|
|
4423
|
+
return ((_a = this._protocol) == null ? void 0 : _a.protocolType) && this._playlistMap ? this._playlistMap[this._protocol.protocolType] : void 0;
|
|
4424
|
+
}
|
|
4425
|
+
static async create(options) {
|
|
4426
|
+
const protocolManager = new _ProtocolManager(options);
|
|
4427
|
+
await protocolManager.getProtocol();
|
|
4428
|
+
return protocolManager;
|
|
4429
|
+
}
|
|
4430
|
+
static _generateProtocolMap(queue, splittedPlaylist, options) {
|
|
4431
|
+
const protocolMap = {};
|
|
4432
|
+
const playlistMap = {};
|
|
4433
|
+
const baseGenerateProtocol = queue.find((type) => {
|
|
4434
|
+
return _ProtocolManager._protocolMap[type].canGenerateOtherProtocol(options) && splittedPlaylist[type];
|
|
4435
|
+
});
|
|
4436
|
+
queue.forEach((protocolType) => {
|
|
4437
|
+
var _a;
|
|
4438
|
+
const playlist = ((_a = _ProtocolManager._protocolMap[protocolType]) == null ? void 0 : _a.generateUrl(
|
|
4439
|
+
splittedPlaylist,
|
|
4440
|
+
{
|
|
4441
|
+
generateUrlFromOtherProtocol: () => {
|
|
4442
|
+
if (!baseGenerateProtocol) {
|
|
4443
|
+
return;
|
|
4444
|
+
}
|
|
4445
|
+
return generateUrlFromOtherProtocol(
|
|
4446
|
+
splittedPlaylist[baseGenerateProtocol],
|
|
4447
|
+
_ProtocolManager._protocolMap[baseGenerateProtocol].suffix,
|
|
4448
|
+
_ProtocolManager._protocolMap[protocolType].suffix
|
|
4449
|
+
);
|
|
4450
|
+
},
|
|
4451
|
+
options
|
|
4452
|
+
}
|
|
4453
|
+
)) ?? splittedPlaylist[protocolType];
|
|
4454
|
+
if (playlist) {
|
|
4455
|
+
playlistMap[protocolType] = playlist;
|
|
4456
|
+
protocolMap[protocolType] = new _ProtocolManager._protocolMap[protocolType](options);
|
|
4457
|
+
}
|
|
4458
|
+
});
|
|
4459
|
+
return { protocolMap, playlistMap };
|
|
4460
|
+
}
|
|
4461
|
+
async getProtocol() {
|
|
4462
|
+
if (this._selector) {
|
|
4463
|
+
this._protocol = await this._selector.getProtocol();
|
|
4464
|
+
}
|
|
4465
|
+
return this._protocol;
|
|
4466
|
+
}
|
|
4467
|
+
async update({
|
|
4468
|
+
url,
|
|
4469
|
+
playlist
|
|
4470
|
+
}) {
|
|
4471
|
+
this._options = { ...this._options, url, playlist };
|
|
4472
|
+
this._init({
|
|
4473
|
+
url,
|
|
4474
|
+
playlist
|
|
4475
|
+
});
|
|
4476
|
+
await this.getProtocol();
|
|
4477
|
+
}
|
|
4478
|
+
async next() {
|
|
4479
|
+
if (!this._selector) {
|
|
4480
|
+
return;
|
|
4481
|
+
}
|
|
4482
|
+
this._selector.next();
|
|
4483
|
+
await this.getProtocol();
|
|
4484
|
+
return this._protocol;
|
|
4485
|
+
}
|
|
4486
|
+
async getStrategy(player, i18n) {
|
|
4487
|
+
var _a, _b, _c;
|
|
4488
|
+
const protocol = this._protocol;
|
|
4489
|
+
const [typeStrategy, drmStrategy, abrStrategy] = await Promise.all([
|
|
4490
|
+
protocol == null ? void 0 : protocol.getProtocolStrategy(this._options, {
|
|
4491
|
+
player,
|
|
4492
|
+
i18n,
|
|
4493
|
+
enableSelector: !!this._selector
|
|
4494
|
+
}),
|
|
4495
|
+
(_a = protocol == null ? void 0 : protocol.getDrmStrategy) == null ? void 0 : _a.call(protocol, this._options, player),
|
|
4496
|
+
(_b = protocol == null ? void 0 : protocol.getAbrStrategy) == null ? void 0 : _b.call(protocol, this._options)
|
|
4497
|
+
]);
|
|
4498
|
+
const { options, plugins } = typeStrategy ?? {};
|
|
4499
|
+
const { options: drmOptions, plugins: drmPlugins } = drmStrategy ?? {};
|
|
4500
|
+
const { options: abrOptions, plugins: abrPlugins } = abrStrategy ?? {};
|
|
4501
|
+
return {
|
|
4502
|
+
options: Object.assign({}, options, drmOptions, abrOptions),
|
|
4503
|
+
plugins: [
|
|
4504
|
+
...plugins ?? [],
|
|
4505
|
+
...drmPlugins ?? [],
|
|
4506
|
+
...abrPlugins ?? []
|
|
4507
|
+
],
|
|
4508
|
+
useSrc: !((_c = typeStrategy == null ? void 0 : typeStrategy.plugins) == null ? void 0 : _c.length),
|
|
4509
|
+
protocol: protocol == null ? void 0 : protocol.protocolType
|
|
4510
|
+
};
|
|
4511
|
+
}
|
|
4512
|
+
_init({
|
|
4513
|
+
url,
|
|
4514
|
+
playlist
|
|
4515
|
+
}) {
|
|
4516
|
+
var _a;
|
|
4517
|
+
if (playlist) {
|
|
4518
|
+
const splittedPlaylist = splitPlaylist(playlist);
|
|
4519
|
+
const Selector = this._options.latencyMode === "low" ? LowLatencySelector : CustomSelector;
|
|
4520
|
+
const queue = (Selector == null ? void 0 : Selector.queue) ?? ((_a = this._options.fallback) == null ? void 0 : _a.fallbackOrder);
|
|
4521
|
+
if (queue == null ? void 0 : queue.length) {
|
|
4522
|
+
const { protocolMap, playlistMap } = _ProtocolManager._generateProtocolMap(
|
|
4523
|
+
queue,
|
|
4524
|
+
splittedPlaylist,
|
|
4525
|
+
this._options
|
|
4526
|
+
);
|
|
4527
|
+
this._playlistMap = playlistMap;
|
|
4528
|
+
this._selector = new Selector({
|
|
4529
|
+
streams: protocolMap,
|
|
4530
|
+
options: this._options
|
|
4531
|
+
});
|
|
4532
|
+
return;
|
|
4533
|
+
}
|
|
4534
|
+
this._playlistMap = splittedPlaylist;
|
|
4535
|
+
this._initSingleProtocol(Object.keys(splittedPlaylist)[0]);
|
|
4536
|
+
} else if (url) {
|
|
4537
|
+
this._initSingleProtocol(getStreamType(url));
|
|
4538
|
+
}
|
|
4539
|
+
}
|
|
4540
|
+
_initSingleProtocol(protocol) {
|
|
4541
|
+
if (protocol) {
|
|
4542
|
+
this._protocol = new _ProtocolManager._protocolMap[protocol](
|
|
4543
|
+
this._options
|
|
4544
|
+
);
|
|
4545
|
+
}
|
|
4546
|
+
}
|
|
4547
|
+
};
|
|
4548
|
+
let ProtocolManager = _ProtocolManager;
|
|
4549
|
+
__publicField(ProtocolManager, "_protocolMap", {
|
|
4550
|
+
[LiveUrlType.Flv]: FlvProtocol,
|
|
4551
|
+
[LiveUrlType.LLFlv]: FlvLowLatencyProtocol,
|
|
4552
|
+
[LiveUrlType.Hls]: HlsProtocol,
|
|
4553
|
+
[LiveUrlType.LLHls]: HlsLowLatencyProtocol,
|
|
4554
|
+
[LiveUrlType.Rtm]: RtmProtocol
|
|
4555
|
+
});
|
|
4556
|
+
class Fallback {
|
|
4557
|
+
constructor() {
|
|
4558
|
+
__publicField(this, "player");
|
|
4559
|
+
__publicField(this, "protocolManager");
|
|
4560
|
+
__publicField(this, "beforeFallbackError", async (error2) => {
|
|
4561
|
+
var _a, _b, _c, _d, _e, _f;
|
|
4562
|
+
if (!((_b = (_a = this.protocolManager) == null ? void 0 : _a.protocol) == null ? void 0 : _b.shouldFallbackWhenError({ error: error2 })) || !((_d = (_c = this.protocolManager) == null ? void 0 : _c.protocol) == null ? void 0 : _d.nextProtocol)) {
|
|
4563
|
+
return { canEmitError: true };
|
|
4564
|
+
}
|
|
4565
|
+
const nextProtocol = await ((_e = this.protocolManager) == null ? void 0 : _e.next());
|
|
4566
|
+
if (!nextProtocol || !((_f = this.protocolManager) == null ? void 0 : _f.playlist)) {
|
|
4567
|
+
return { canEmitError: true };
|
|
4568
|
+
}
|
|
4569
|
+
this.fallback();
|
|
4570
|
+
return { canEmitError: false };
|
|
4571
|
+
});
|
|
4572
|
+
}
|
|
4573
|
+
initErrorFallback(player, protocolManager) {
|
|
4574
|
+
this.player = player;
|
|
4575
|
+
this.protocolManager = protocolManager;
|
|
4576
|
+
}
|
|
4577
|
+
async fallback() {
|
|
4578
|
+
var _a, _b, _c, _d;
|
|
4579
|
+
if (!((_a = this.protocolManager) == null ? void 0 : _a.playlist))
|
|
4580
|
+
return;
|
|
4581
|
+
const definition = (_b = this.player) == null ? void 0 : _b.definition;
|
|
4582
|
+
const source = (_c = this.player) == null ? void 0 : _c.source;
|
|
4583
|
+
(_d = this.player) == null ? void 0 : _d.updatePlaylist(
|
|
4584
|
+
this.protocolManager.playlist,
|
|
4585
|
+
{
|
|
4586
|
+
definition,
|
|
4587
|
+
source
|
|
4588
|
+
},
|
|
4589
|
+
false
|
|
4590
|
+
);
|
|
4591
|
+
}
|
|
4592
|
+
}
|
|
4593
|
+
const fallback = new Fallback();
|
|
3957
4594
|
const DEFAULT_PLUGINS = window["VePlayer"].DEFAULT_PLUGINS;
|
|
3958
4595
|
const VePlayerBase = window["VePlayer"].VePlayerBase;
|
|
3959
4596
|
const VeI18n = window["VePlayer"].VeI18n;
|
|
@@ -3988,6 +4625,7 @@ class VePlayerLive extends VePlayerBase {
|
|
|
3988
4625
|
*/
|
|
3989
4626
|
constructor(options) {
|
|
3990
4627
|
super(options);
|
|
4628
|
+
__publicField(this, "_protocolManager");
|
|
3991
4629
|
}
|
|
3992
4630
|
/** {zh}
|
|
3993
4631
|
* @brief 获取已经播放的时长,不包含暂停和等待时间,单位为秒。
|
|
@@ -4009,6 +4647,12 @@ class VePlayerLive extends VePlayerBase {
|
|
|
4009
4647
|
}
|
|
4010
4648
|
return time;
|
|
4011
4649
|
}
|
|
4650
|
+
/** {en}
|
|
4651
|
+
* @hidden
|
|
4652
|
+
*/
|
|
4653
|
+
/** {zh}
|
|
4654
|
+
* @hidden
|
|
4655
|
+
*/
|
|
4012
4656
|
get ad() {
|
|
4013
4657
|
var _a, _b;
|
|
4014
4658
|
return (_b = (_a = this._player.plugins) == null ? void 0 : _a.ad) == null ? void 0 : _b.adManager;
|
|
@@ -4161,6 +4805,13 @@ class VePlayerLive extends VePlayerBase {
|
|
|
4161
4805
|
var _a, _b, _c;
|
|
4162
4806
|
return (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.flv) == null ? void 0 : _c.getStats();
|
|
4163
4807
|
}
|
|
4808
|
+
async updatePlaylist(playlist, target, needUpdateProtocol = true) {
|
|
4809
|
+
var _a;
|
|
4810
|
+
if (needUpdateProtocol) {
|
|
4811
|
+
await ((_a = this._protocolManager) == null ? void 0 : _a.update({ playlist }));
|
|
4812
|
+
}
|
|
4813
|
+
return super.updatePlaylist(playlist, target);
|
|
4814
|
+
}
|
|
4164
4815
|
}
|
|
4165
4816
|
async function createLivePlayer(options) {
|
|
4166
4817
|
var _a, _b, _c, _d;
|
|
@@ -4179,10 +4830,16 @@ async function createLivePlayer(options) {
|
|
|
4179
4830
|
...options,
|
|
4180
4831
|
plugins: [...LIVE_DEFAULT_PLUGINS, ...options.plugins ?? []]
|
|
4181
4832
|
};
|
|
4833
|
+
const protocolManager = await ProtocolManager.create(finalOptions);
|
|
4834
|
+
if (!options.url && !(protocolManager == null ? void 0 : protocolManager.playlist)) {
|
|
4835
|
+
throw create(ErrorCode.INVALID_PARAMETER, i18n);
|
|
4836
|
+
}
|
|
4182
4837
|
player = await VePlayerBase.create(
|
|
4183
4838
|
{
|
|
4184
4839
|
...LIVE_DEFAULT_OPTIONS,
|
|
4185
4840
|
...finalOptions,
|
|
4841
|
+
playlist: protocolManager == null ? void 0 : protocolManager.playlist,
|
|
4842
|
+
beforeFallbackError: fallback.beforeFallbackError,
|
|
4186
4843
|
isLive: true,
|
|
4187
4844
|
i18nManager: i18n,
|
|
4188
4845
|
preProcessUrl: (url) => {
|
|
@@ -4194,44 +4851,16 @@ async function createLivePlayer(options) {
|
|
|
4194
4851
|
};
|
|
4195
4852
|
},
|
|
4196
4853
|
async preparePlugins(url) {
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
...finalOptions,
|
|
4202
|
-
url
|
|
4203
|
-
},
|
|
4204
|
-
player,
|
|
4205
|
-
i18n
|
|
4206
|
-
),
|
|
4207
|
-
getDrmStrategy(
|
|
4208
|
-
{
|
|
4209
|
-
...finalOptions,
|
|
4210
|
-
url
|
|
4211
|
-
},
|
|
4212
|
-
player
|
|
4213
|
-
),
|
|
4214
|
-
getAbrStrategy({
|
|
4215
|
-
...finalOptions,
|
|
4216
|
-
url
|
|
4217
|
-
})
|
|
4218
|
-
]);
|
|
4219
|
-
const { options: options2, plugins } = typeStrategy ?? {};
|
|
4220
|
-
const { options: drmOptions, plugins: drmPlugins } = drmStrategy ?? {};
|
|
4221
|
-
const { options: abrOptions, plugins: abrPlugins } = abrStrategy ?? {};
|
|
4222
|
-
return {
|
|
4223
|
-
options: Object.assign({}, options2, drmOptions, abrOptions),
|
|
4224
|
-
plugins: [
|
|
4225
|
-
...plugins ?? [],
|
|
4226
|
-
...drmPlugins ?? [],
|
|
4227
|
-
...abrPlugins ?? []
|
|
4228
|
-
],
|
|
4229
|
-
useSrc: !((_a2 = typeStrategy.plugins) == null ? void 0 : _a2.length)
|
|
4230
|
-
};
|
|
4854
|
+
if (!protocolManager.enableSelector) {
|
|
4855
|
+
await protocolManager.update({ url });
|
|
4856
|
+
}
|
|
4857
|
+
return protocolManager.getStrategy(player, i18n);
|
|
4231
4858
|
}
|
|
4232
4859
|
},
|
|
4233
4860
|
VePlayerLive
|
|
4234
4861
|
);
|
|
4862
|
+
player._protocolManager = protocolManager;
|
|
4863
|
+
fallback.initErrorFallback(player, protocolManager);
|
|
4235
4864
|
if (player) {
|
|
4236
4865
|
const RTMDegrade = (_d = (_c = player == null ? void 0 : player._player) == null ? void 0 : _c.config) == null ? void 0 : _d._RTMdegrade;
|
|
4237
4866
|
if (RTMDegrade) {
|