@volcengine/veplayer 2.0.0-rc.2 → 2.1.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/README.md +14 -1
- package/esm/index.d.ts +17 -11
- package/esm/veplayer.biz.live.development.js +184 -45
- package/esm/veplayer.biz.live.production.js +1 -1
- package/esm/veplayer.d.ts +53 -28
- package/esm/veplayer.development.css +1 -1
- package/esm/veplayer.development.js +600 -234
- package/esm/veplayer.live.d.ts +53 -28
- package/esm/veplayer.live.development.css +1 -1
- package/esm/veplayer.live.development.js +600 -234
- package/esm/veplayer.live.production.css +1 -1
- package/esm/veplayer.live.production.js +4 -4
- package/esm/veplayer.production.css +1 -1
- package/esm/veplayer.production.js +4 -4
- package/esm/veplayer.vod.d.ts +17 -11
- package/esm/veplayer.vod.development.css +1 -1
- package/esm/veplayer.vod.development.js +402 -173
- package/esm/veplayer.vod.production.css +1 -1
- package/esm/veplayer.vod.production.js +4 -4
- package/package.json +2 -1
- package/umd/index.d.ts +17 -11
- package/umd/veplayer.biz.live.development.js +184 -45
- package/umd/veplayer.biz.live.production.js +1 -1
- package/umd/veplayer.d.ts +53 -28
- package/umd/veplayer.development.css +1 -1
- package/umd/veplayer.development.js +600 -234
- package/umd/veplayer.live.d.ts +53 -28
- package/umd/veplayer.live.development.css +1 -1
- package/umd/veplayer.live.development.js +598 -232
- package/umd/veplayer.live.production.css +1 -1
- package/umd/veplayer.live.production.js +1 -1
- package/umd/veplayer.production.css +1 -1
- package/umd/veplayer.production.js +1 -1
- package/umd/veplayer.vod.d.ts +17 -11
- package/umd/veplayer.vod.development.css +1 -1
- package/umd/veplayer.vod.development.js +402 -173
- package/umd/veplayer.vod.production.css +1 -1
- package/umd/veplayer.vod.production.js +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# VePlayer
|
|
2
2
|
|
|
3
3
|
## 简介
|
|
4
|
+
视频云播放器(VePlayer)是一款 Web 端的点直播播放 SDK,结合火山引擎点直播服务,为您提供流畅、稳定、高品质的点直播解决方案,支持便捷接入、跨端兼容。帮助您一站式快速搭建自己的点直播播放器。
|
|
5
|
+
|
|
6
|
+
## 安装
|
|
7
|
+
```node
|
|
8
|
+
npm install @volcengine/veplayer
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 直播 API 文档
|
|
12
|
+
[接入指引](https://www.volcengine.com/docs/6469/127528) <br>
|
|
13
|
+
[功能接入](https://www.volcengine.com/docs/6469/138655)<br>
|
|
14
|
+
[配置](https://www.volcengine.com/docs/6469/1155423)<br>
|
|
15
|
+
[方法及属性](https://www.volcengine.com/docs/6469/1156178)<br>
|
|
16
|
+
[事件](https://www.volcengine.com/docs/6469/1158676)<br>
|
|
17
|
+
[错误码](https://www.volcengine.com/docs/6469/1158675)
|
|
4
18
|
|
|
5
|
-
这是 VePlayer 的导出包,本身不包含任何实现。
|
package/esm/index.d.ts
CHANGED
|
@@ -79,7 +79,7 @@ declare class VeI18n<T extends string = TextKey> {
|
|
|
79
79
|
texts?: Record<Lang, Record<string, string>>;
|
|
80
80
|
};
|
|
81
81
|
});
|
|
82
|
-
static get langKeys():
|
|
82
|
+
static get langKeys(): string[];
|
|
83
83
|
static isLangValid(lang: Lang): boolean;
|
|
84
84
|
static extend(i18nTextList: Array<IXGI18nText>, i18nLangs?: IXGI18n): void;
|
|
85
85
|
setLang(lang: string): void;
|
|
@@ -106,6 +106,7 @@ declare class Definition implements XGDefinition {
|
|
|
106
106
|
fallbackUrls?: string[];
|
|
107
107
|
});
|
|
108
108
|
get url(): string;
|
|
109
|
+
set url(url: string);
|
|
109
110
|
next(): DefinitionUrl;
|
|
110
111
|
}
|
|
111
112
|
/**
|
|
@@ -1162,11 +1163,11 @@ declare class VePlayerBase {
|
|
|
1162
1163
|
* @brief 获取和设置当前语言。
|
|
1163
1164
|
*/
|
|
1164
1165
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
1165
|
-
get lang(): "zh-cn" | "
|
|
1166
|
+
get lang(): "zh-cn" | "en" | string;
|
|
1166
1167
|
/**
|
|
1167
1168
|
* @brief 获取和设置当前语言。
|
|
1168
1169
|
*/
|
|
1169
|
-
set lang(lang: "zh-cn" | "
|
|
1170
|
+
set lang(lang: "zh-cn" | "en" | string);
|
|
1170
1171
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
1171
1172
|
protected get _src(): string;
|
|
1172
1173
|
/**
|
|
@@ -1296,7 +1297,7 @@ declare class VePlayerBase {
|
|
|
1296
1297
|
* @brief 调用此方法进入系统全屏状态。如果该方法调用的时候处于网页全屏状态会自动退出网页全屏,下发事件 `Events.FULLSCREEN_CHANGE`。
|
|
1297
1298
|
* @param el 全屏作用的 DOM 节点。
|
|
1298
1299
|
*/
|
|
1299
|
-
|
|
1300
|
+
requestFullscreen(el?: HTMLElement): Promise<void>;
|
|
1300
1301
|
/**
|
|
1301
1302
|
* @brief 调用此方法退出系统全屏状态,调用该方法 `veplayer.isFullscreen` 将会变为 `false`,并触发 `Events.FULLSCREEN_CHANGE` 事件。
|
|
1302
1303
|
* @param el 全屏作用的 DOM 节点。
|
|
@@ -1306,7 +1307,7 @@ declare class VePlayerBase {
|
|
|
1306
1307
|
* @brief 调用此方法进入网页样式全屏状态,播放器进入网页全屏,利用 CSS 模拟实现全屏效果。如果该接口调用的时候处于全屏状态,会自动退出全屏,下发事件 `Events.CSS_FULLSCREEN_CHANGE`。
|
|
1307
1308
|
* @param el 全屏作用的 DOM 节点。
|
|
1308
1309
|
*/
|
|
1309
|
-
|
|
1310
|
+
requestCssFullscreen(el?: HTMLElement): void;
|
|
1310
1311
|
/**
|
|
1311
1312
|
* @brief 调用此方法退出网页样式全屏状态。 调用该方法 `veplayer.isFullscreen` 将会变为 `false`,并触发 `Events.CSS_FULLSCREEN_CHANGE` 事件。
|
|
1312
1313
|
*/
|
|
@@ -1355,7 +1356,10 @@ declare class VePlayerBase {
|
|
|
1355
1356
|
/**
|
|
1356
1357
|
* @hidden
|
|
1357
1358
|
*/
|
|
1358
|
-
prepare(url: string): Promise<
|
|
1359
|
+
prepare(url: string): Promise<{
|
|
1360
|
+
plugins: any[];
|
|
1361
|
+
options: Partial<VePlayerBaseOptions> | undefined;
|
|
1362
|
+
}>;
|
|
1359
1363
|
private _handleFallback;
|
|
1360
1364
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1361
1365
|
private _transformEvent;
|
|
@@ -1542,7 +1546,7 @@ declare namespace strategy {
|
|
|
1542
1546
|
texts?: Record<Lang, Record<string, string>>;
|
|
1543
1547
|
};
|
|
1544
1548
|
});
|
|
1545
|
-
static get langKeys():
|
|
1549
|
+
static get langKeys(): string[];
|
|
1546
1550
|
static isLangValid(lang: Lang): boolean;
|
|
1547
1551
|
static extend(i18nTextList: Array<IXGI18nText>, i18nLangs?: IXGI18n): void;
|
|
1548
1552
|
setLang(lang: string): void;
|
|
@@ -1570,6 +1574,7 @@ declare namespace strategy {
|
|
|
1570
1574
|
fallbackUrls?: string[];
|
|
1571
1575
|
});
|
|
1572
1576
|
get url(): string;
|
|
1577
|
+
set url(url: string);
|
|
1573
1578
|
next(): DefinitionUrl;
|
|
1574
1579
|
}
|
|
1575
1580
|
/**
|
|
@@ -2021,7 +2026,6 @@ declare namespace strategy {
|
|
|
2021
2026
|
ext?: any;
|
|
2022
2027
|
error?: Error;
|
|
2023
2028
|
}
|
|
2024
|
-
// 参考: https://bytedance.feishu.cn/docx/doxcnGPXIOrJk3dGE3E3YghgZke
|
|
2025
2029
|
const ERROR_INFO: Partial<Record<ErrorCode, ErrorInfo>>;
|
|
2026
2030
|
const ERROR_TYPE_INFO: Record<ErrorType, ErrorInfo>;
|
|
2027
2031
|
/**
|
|
@@ -2196,7 +2200,9 @@ declare namespace strategy {
|
|
|
2196
2200
|
};
|
|
2197
2201
|
renderItemList(): void;
|
|
2198
2202
|
onItemClick(_: never, data: {
|
|
2199
|
-
to: Definition
|
|
2203
|
+
to: Definition & {
|
|
2204
|
+
showText: string;
|
|
2205
|
+
};
|
|
2200
2206
|
}): void;
|
|
2201
2207
|
fallback(options?: {
|
|
2202
2208
|
toast: boolean;
|
|
@@ -2799,7 +2805,7 @@ declare namespace error {
|
|
|
2799
2805
|
texts?: Record<Lang, Record<string, string>>;
|
|
2800
2806
|
};
|
|
2801
2807
|
});
|
|
2802
|
-
static get langKeys():
|
|
2808
|
+
static get langKeys(): string[];
|
|
2803
2809
|
static isLangValid(lang: Lang): boolean;
|
|
2804
2810
|
static extend(i18nTextList: Array<IXGI18nText>, i18nLangs?: IXGI18n): void;
|
|
2805
2811
|
setLang(lang: string): void;
|
|
@@ -3027,7 +3033,6 @@ declare namespace error {
|
|
|
3027
3033
|
ext?: any;
|
|
3028
3034
|
error?: Error;
|
|
3029
3035
|
}
|
|
3030
|
-
// 参考: https://bytedance.feishu.cn/docx/doxcnGPXIOrJk3dGE3E3YghgZke
|
|
3031
3036
|
const ERROR_INFO: Partial<Record<ErrorCode, ErrorInfo>>;
|
|
3032
3037
|
const ERROR_TYPE_INFO: Record<ErrorType, ErrorInfo>;
|
|
3033
3038
|
/**
|
|
@@ -3127,6 +3132,7 @@ declare namespace event {
|
|
|
3127
3132
|
DURATION_CHANGE: string;
|
|
3128
3133
|
VOLUME_CHANGE: string;
|
|
3129
3134
|
LOADED_DATA: string;
|
|
3135
|
+
LOADED_METADATA: string;
|
|
3130
3136
|
RATE_CHANGE: string;
|
|
3131
3137
|
PROGRESS: string;
|
|
3132
3138
|
LOAD_START: string;
|
|
@@ -28,6 +28,18 @@ const ERRORS = {
|
|
|
28
28
|
function create(errorCode, i18n) {
|
|
29
29
|
return new VeError(ERRORS[errorCode], i18n);
|
|
30
30
|
}
|
|
31
|
+
const DynamicModule$2 = window["VePlayer"].DynamicModule;
|
|
32
|
+
const load$2 = window["VePlayer"].load;
|
|
33
|
+
async function isRTMSupported() {
|
|
34
|
+
const Rtm = await load$2(DynamicModule$2.PluginRtm);
|
|
35
|
+
return Rtm.isSupported();
|
|
36
|
+
}
|
|
37
|
+
async function isRTMSupportCodec(codec = RTMCodec.H264) {
|
|
38
|
+
const Rtm = await load$2(DynamicModule$2.PluginRtm);
|
|
39
|
+
if (codec === RTMCodec.H264)
|
|
40
|
+
return Rtm.isSupportedH264();
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
31
43
|
const strategy$1 = window["VePlayer"].strategy;
|
|
32
44
|
const util$3 = window["VePlayer"].util;
|
|
33
45
|
const DynamicModule$1 = window["VePlayer"].DynamicModule;
|
|
@@ -38,11 +50,20 @@ const rtmStrategy = {
|
|
|
38
50
|
options: {},
|
|
39
51
|
module: DynamicModule$1.PluginRtm
|
|
40
52
|
};
|
|
41
|
-
const
|
|
53
|
+
const generateFallbackUrl = (url) => {
|
|
54
|
+
if (Sniffer$2.device === "pc") {
|
|
55
|
+
return url.replace(".sdp", ".flv");
|
|
56
|
+
} else {
|
|
57
|
+
return url.replace(".sdp", ".m3u8");
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const getRtmStrategy = async (options, player) => {
|
|
42
61
|
var _a;
|
|
43
62
|
let backupStrategy;
|
|
44
|
-
const {
|
|
45
|
-
const
|
|
63
|
+
const { url } = options;
|
|
64
|
+
const { fallbackUrl, enableFallback = true, ...ret } = options.rtm || {};
|
|
65
|
+
const actualFallbackUrl = !enableFallback ? "" : !fallbackUrl && url ? generateFallbackUrl(url) : fallbackUrl;
|
|
66
|
+
const backupType = actualFallbackUrl && util$3.getStreamType(actualFallbackUrl);
|
|
46
67
|
if (backupType === "flv" && util$3.isMseSupported(Codec$1.H264)) {
|
|
47
68
|
backupStrategy = strategy$1.createFlvMseStrategy(options);
|
|
48
69
|
} else if (backupType === "hls" && (Sniffer$2.device !== "mobile" || ((_a = options == null ? void 0 : options.hls) == null ? void 0 : _a.enableMSE)) && util$3.isMseSupported(Codec$1.H264)) {
|
|
@@ -52,42 +73,57 @@ const getRtmStrategy = async (options) => {
|
|
|
52
73
|
load$1(rtmStrategy.module).catch(() => void 0),
|
|
53
74
|
backupStrategy && load$1(backupStrategy.module).catch(() => void 0)
|
|
54
75
|
]);
|
|
76
|
+
const [RTMSupported, RTMSupportCodec] = await Promise.all([
|
|
77
|
+
isRTMSupported(),
|
|
78
|
+
isRTMSupportCodec()
|
|
79
|
+
]);
|
|
80
|
+
if (!RTMSupported || !RTMSupportCodec) {
|
|
81
|
+
if (player) {
|
|
82
|
+
player.emit("degrade", {
|
|
83
|
+
url: actualFallbackUrl,
|
|
84
|
+
originRtmUrl: url,
|
|
85
|
+
code: "NOT_SUPPORT",
|
|
86
|
+
message: "not support rtm or h264",
|
|
87
|
+
isRTMSupported: RTMSupported,
|
|
88
|
+
isRTMSupportCodec: RTMSupportCodec
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
options: {
|
|
93
|
+
...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
|
|
94
|
+
url: actualFallbackUrl,
|
|
95
|
+
_RTMdegrade: {
|
|
96
|
+
_originRtmUrl: url,
|
|
97
|
+
_isRTMSupported: RTMSupported,
|
|
98
|
+
_isRTMSupportCodec: RTMSupportCodec
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
plugins: backupCdn ? [backupCdn] : []
|
|
102
|
+
};
|
|
103
|
+
}
|
|
55
104
|
return {
|
|
56
105
|
options: {
|
|
57
106
|
...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
|
|
107
|
+
_RTMdegrade: void 0,
|
|
58
108
|
rts: {
|
|
59
109
|
retryCount: 0,
|
|
60
110
|
...ret,
|
|
61
|
-
backupURL:
|
|
111
|
+
backupURL: actualFallbackUrl,
|
|
62
112
|
backupConstruct: backupCdn
|
|
63
113
|
}
|
|
64
114
|
},
|
|
65
115
|
plugins: rtmCdn ? [rtmCdn] : []
|
|
66
116
|
};
|
|
67
117
|
};
|
|
68
|
-
var RTMCodec = /* @__PURE__ */ ((RTMCodec2) => {
|
|
69
|
-
RTMCodec2["H264"] = "h264";
|
|
70
|
-
return RTMCodec2;
|
|
71
|
-
})(RTMCodec || {});
|
|
72
|
-
const isRTMSupported = async () => {
|
|
73
|
-
const Rtm = await load$1(DynamicModule$1.PluginRtm);
|
|
74
|
-
return Rtm.isSupported();
|
|
75
|
-
};
|
|
76
|
-
const isRTMSupportCodec = async (codec = "h264") => {
|
|
77
|
-
const Rtm = await load$1(DynamicModule$1.PluginRtm);
|
|
78
|
-
if (codec === "h264")
|
|
79
|
-
return Rtm.isSupportedH264();
|
|
80
|
-
return false;
|
|
81
|
-
};
|
|
82
118
|
const util$2 = window["VePlayer"].util;
|
|
83
119
|
const strategy = window["VePlayer"].strategy;
|
|
84
|
-
const getTypeStrategy = async (options) => {
|
|
120
|
+
const getTypeStrategy = async (options, player) => {
|
|
85
121
|
const type = options.url ? util$2.getStreamType(options.url) : "";
|
|
86
122
|
if (!type || type === "unknown") {
|
|
87
123
|
return { options: {}, plugins: [] };
|
|
88
124
|
}
|
|
89
125
|
if (type === "rtm") {
|
|
90
|
-
return await getRtmStrategy(options);
|
|
126
|
+
return await getRtmStrategy(options, player);
|
|
91
127
|
}
|
|
92
128
|
if (type === "flv") {
|
|
93
129
|
return await strategy.getFlvStrategy(options);
|
|
@@ -543,9 +579,9 @@ function getPlayFormat(url) {
|
|
|
543
579
|
function isCodecSupport(codec) {
|
|
544
580
|
return typeof MediaSource !== "undefined" ? +MediaSource.isTypeSupported("video/mp4; codecs=" + codec) : 0;
|
|
545
581
|
}
|
|
546
|
-
function getUrlQuery(url, key) {
|
|
582
|
+
function getUrlQuery(url, key, key2) {
|
|
547
583
|
var x2 = new URLSearchParams(url.split("?")[1]);
|
|
548
|
-
return x2.get(key);
|
|
584
|
+
return x2.get(key) || x2.get(key2);
|
|
549
585
|
}
|
|
550
586
|
function getDeviceInfo() {
|
|
551
587
|
var res = {
|
|
@@ -572,19 +608,11 @@ function getPlayerCore(player) {
|
|
|
572
608
|
return player.plugins.hls;
|
|
573
609
|
} else if (player.plugins.rts) {
|
|
574
610
|
return player.plugins.rts;
|
|
575
|
-
} else if (player.plugins.
|
|
576
|
-
return player.plugins.
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
return player.plugins.hlsvod;
|
|
581
|
-
} else if (player.plugins.hlslivemobile) {
|
|
582
|
-
return player.plugins.hlslivemobile;
|
|
583
|
-
} else if (player.plugins.flvlivemobile) {
|
|
584
|
-
return player.plugins.flvlivemobile;
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
return player.newHls || player.newFlv || player.__core__ || player.flv;
|
|
611
|
+
} else if (player.plugins.rtm) {
|
|
612
|
+
return player.plugins.rtm;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return null;
|
|
588
616
|
}
|
|
589
617
|
function getDefaultOptions(options) {
|
|
590
618
|
return {
|
|
@@ -813,7 +841,7 @@ function getCommonLog(options) {
|
|
|
813
841
|
live_sdk_version: getPlayerCore(player) || player.hlsOps ? "2" : "-1",
|
|
814
842
|
player_sdk_version: player.version,
|
|
815
843
|
// eslint-disable-next-line no-undef
|
|
816
|
-
logger_version: "1.1.0-alpha.
|
|
844
|
+
logger_version: "1.1.0-alpha.7",
|
|
817
845
|
// 由rollup 在编译时注入
|
|
818
846
|
report_version: "5",
|
|
819
847
|
product_line: options.product_line,
|
|
@@ -937,9 +965,13 @@ var Manage = /* @__PURE__ */ function() {
|
|
|
937
965
|
if (this._player.video) {
|
|
938
966
|
log.play_current_time = this._player.currentTime;
|
|
939
967
|
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
968
|
+
if (this.core && this.core.loader && this.core.loader.finnalUrl) {
|
|
969
|
+
log.cdn_play_url = this.core.loader.finnalUrl;
|
|
970
|
+
} else {
|
|
971
|
+
log.cdn_play_url = url && url.startsWith("//") ? window.location.protocol + url : url;
|
|
972
|
+
}
|
|
973
|
+
log.live_stream_session_id = getUrlQuery(log.cdn_play_url, "_session_id", "session_id");
|
|
974
|
+
log.play_format = getPlayFormat(log.cdn_play_url);
|
|
943
975
|
log.timestamp = getCurrentTime();
|
|
944
976
|
var _getDeviceInfo = getDeviceInfo(), cpu_core_number = _getDeviceInfo.cpu_core_number, memory_usage = _getDeviceInfo.memory_usage, network_downlink = _getDeviceInfo.network_downlink;
|
|
945
977
|
log.cpu_core_number = cpu_core_number;
|
|
@@ -1165,6 +1197,11 @@ var XgLiveLogger = /* @__PURE__ */ function() {
|
|
|
1165
1197
|
};
|
|
1166
1198
|
_proto2.reportStartPlay = function reportStartPlay() {
|
|
1167
1199
|
if (!this.started) {
|
|
1200
|
+
this.core = getPlayerCore(this.player);
|
|
1201
|
+
if (this.core) {
|
|
1202
|
+
this.commonParams.live_sdk_version = "2";
|
|
1203
|
+
this.logmanager.core = this.core;
|
|
1204
|
+
}
|
|
1168
1205
|
this.started = true;
|
|
1169
1206
|
this.log.start_play.start_play_time = this.log.start_play.timestamp = getCurrentTime();
|
|
1170
1207
|
this.logmanager.push(this.log.start_play, true);
|
|
@@ -1429,6 +1466,7 @@ var XgLiveLogger = /* @__PURE__ */ function() {
|
|
|
1429
1466
|
this.core = getPlayerCore(this.player);
|
|
1430
1467
|
if (this.core) {
|
|
1431
1468
|
this.commonParams.live_sdk_version = "2";
|
|
1469
|
+
this.logmanager.core = this.core;
|
|
1432
1470
|
}
|
|
1433
1471
|
if (this.player.config.autoplay || this.player.config.videoInit) {
|
|
1434
1472
|
this.reportStartPlay();
|
|
@@ -2681,6 +2719,45 @@ var T = 4003, C = function() {
|
|
|
2681
2719
|
this.event("predefine_pageview", n2);
|
|
2682
2720
|
}, t2;
|
|
2683
2721
|
}(), q = new R("default");
|
|
2722
|
+
let getRandomValues;
|
|
2723
|
+
const rnds8 = new Uint8Array(16);
|
|
2724
|
+
function rng() {
|
|
2725
|
+
if (!getRandomValues) {
|
|
2726
|
+
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
2727
|
+
if (!getRandomValues) {
|
|
2728
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
2729
|
+
}
|
|
2730
|
+
}
|
|
2731
|
+
return getRandomValues(rnds8);
|
|
2732
|
+
}
|
|
2733
|
+
const byteToHex = [];
|
|
2734
|
+
for (let i2 = 0; i2 < 256; ++i2) {
|
|
2735
|
+
byteToHex.push((i2 + 256).toString(16).slice(1));
|
|
2736
|
+
}
|
|
2737
|
+
function unsafeStringify(arr, offset = 0) {
|
|
2738
|
+
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
|
2739
|
+
}
|
|
2740
|
+
const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
2741
|
+
var native = {
|
|
2742
|
+
randomUUID
|
|
2743
|
+
};
|
|
2744
|
+
function v4(options, buf, offset) {
|
|
2745
|
+
if (native.randomUUID && !buf && !options) {
|
|
2746
|
+
return native.randomUUID();
|
|
2747
|
+
}
|
|
2748
|
+
options = options || {};
|
|
2749
|
+
const rnds = options.random || (options.rng || rng)();
|
|
2750
|
+
rnds[6] = rnds[6] & 15 | 64;
|
|
2751
|
+
rnds[8] = rnds[8] & 63 | 128;
|
|
2752
|
+
if (buf) {
|
|
2753
|
+
offset = offset || 0;
|
|
2754
|
+
for (let i2 = 0; i2 < 16; ++i2) {
|
|
2755
|
+
buf[offset + i2] = rnds[i2];
|
|
2756
|
+
}
|
|
2757
|
+
return buf;
|
|
2758
|
+
}
|
|
2759
|
+
return unsafeStringify(rnds);
|
|
2760
|
+
}
|
|
2684
2761
|
const DEVICE_ID_KEY = "veplayer_live_device_id";
|
|
2685
2762
|
const USER_ID_Key = "veplayer_live_user_id";
|
|
2686
2763
|
const genRandomID2 = (length) => {
|
|
@@ -2706,6 +2783,45 @@ const getUserId2 = () => {
|
|
|
2706
2783
|
localStorage.setItem(USER_ID_Key, userId);
|
|
2707
2784
|
return userId;
|
|
2708
2785
|
};
|
|
2786
|
+
const generateUrlWithSessionId = (url) => {
|
|
2787
|
+
var _a, _b;
|
|
2788
|
+
if (!url) {
|
|
2789
|
+
return "";
|
|
2790
|
+
}
|
|
2791
|
+
const withoutProtocol = url.startsWith("//");
|
|
2792
|
+
if (withoutProtocol) {
|
|
2793
|
+
url = location.protocol + url;
|
|
2794
|
+
}
|
|
2795
|
+
try {
|
|
2796
|
+
const urlObject = new URL(url);
|
|
2797
|
+
if ((_a = urlObject == null ? void 0 : urlObject.searchParams) == null ? void 0 : _a.get("_session_id")) {
|
|
2798
|
+
return url;
|
|
2799
|
+
}
|
|
2800
|
+
(_b = urlObject == null ? void 0 : urlObject.searchParams) == null ? void 0 : _b.append("_session_id", generateSessionId());
|
|
2801
|
+
return urlObject.toString();
|
|
2802
|
+
} catch (error2) {
|
|
2803
|
+
return url;
|
|
2804
|
+
}
|
|
2805
|
+
};
|
|
2806
|
+
const hashCode = (str) => {
|
|
2807
|
+
str += "";
|
|
2808
|
+
let h2 = 0;
|
|
2809
|
+
let off = 0;
|
|
2810
|
+
const len = str.length;
|
|
2811
|
+
for (let i2 = 0; i2 < len; i2++) {
|
|
2812
|
+
h2 = 31 * h2 + str.charCodeAt(off++);
|
|
2813
|
+
if (h2 > 140737488355327 || h2 < -140737488355328) {
|
|
2814
|
+
h2 &= 281474976710655;
|
|
2815
|
+
}
|
|
2816
|
+
}
|
|
2817
|
+
if (h2 < 0) {
|
|
2818
|
+
h2 += 2251799813685247;
|
|
2819
|
+
}
|
|
2820
|
+
return h2;
|
|
2821
|
+
};
|
|
2822
|
+
const generateSessionId = () => {
|
|
2823
|
+
return v4().replace(/-/g, "") + "." + Date.now() + "." + hashCode(v4().replace(/-/g, ""));
|
|
2824
|
+
};
|
|
2709
2825
|
const Plugin$2 = window["VePlayer"].Plugin;
|
|
2710
2826
|
const CN_APPID = 468759;
|
|
2711
2827
|
const CHANNEL = "cn";
|
|
@@ -2785,10 +2901,10 @@ class Logger extends Plugin$2 {
|
|
|
2785
2901
|
user_id: this._userId,
|
|
2786
2902
|
device_id: this._deviceId,
|
|
2787
2903
|
ext: {
|
|
2788
|
-
veplayer_version: "2.
|
|
2789
|
-
flv_version: "3.0.
|
|
2790
|
-
hls_version: "3.0.
|
|
2791
|
-
rts_version: "0.2.0-alpha.
|
|
2904
|
+
veplayer_version: "2.1.0-rc.0",
|
|
2905
|
+
flv_version: "3.0.10-alpha.4",
|
|
2906
|
+
hls_version: "3.0.10-alpha.4",
|
|
2907
|
+
rts_version: "0.2.0-alpha.5"
|
|
2792
2908
|
}
|
|
2793
2909
|
});
|
|
2794
2910
|
}
|
|
@@ -3073,6 +3189,10 @@ const LIVE_DEFAULT_OPTIONS = {
|
|
|
3073
3189
|
autoplay: { muted: true }
|
|
3074
3190
|
};
|
|
3075
3191
|
const LIVE_DEFAULT_PLUGINS = [...DEFAULT_PLUGINS, Refresh, Logger, InfoPanel];
|
|
3192
|
+
var RTMCodec = /* @__PURE__ */ ((RTMCodec2) => {
|
|
3193
|
+
RTMCodec2["H264"] = "h264";
|
|
3194
|
+
return RTMCodec2;
|
|
3195
|
+
})(RTMCodec || {});
|
|
3076
3196
|
class VePlayerLive extends VePlayerBase {
|
|
3077
3197
|
/**
|
|
3078
3198
|
* @hidden
|
|
@@ -3112,6 +3232,8 @@ class VePlayerLive extends VePlayerBase {
|
|
|
3112
3232
|
}
|
|
3113
3233
|
}
|
|
3114
3234
|
async function createLivePlayer(options) {
|
|
3235
|
+
var _a, _b;
|
|
3236
|
+
let player = void 0;
|
|
3115
3237
|
if (!options || !options.url && !options.playlist) {
|
|
3116
3238
|
throw create(ErrorCode.INVALID_PARAMETER, new VeI18n());
|
|
3117
3239
|
}
|
|
@@ -3120,18 +3242,35 @@ async function createLivePlayer(options) {
|
|
|
3120
3242
|
...options,
|
|
3121
3243
|
plugins: [...LIVE_DEFAULT_PLUGINS, ...options.plugins ?? []]
|
|
3122
3244
|
};
|
|
3123
|
-
|
|
3245
|
+
player = await VePlayerBase.create(
|
|
3124
3246
|
{
|
|
3125
3247
|
...LIVE_DEFAULT_OPTIONS,
|
|
3126
3248
|
...finalOptions,
|
|
3127
3249
|
isLive: true,
|
|
3128
3250
|
i18nManager: i18n,
|
|
3251
|
+
preProcessUrl: (url) => {
|
|
3252
|
+
return {
|
|
3253
|
+
url: generateUrlWithSessionId(url)
|
|
3254
|
+
};
|
|
3255
|
+
},
|
|
3129
3256
|
async preparePlugins(url) {
|
|
3130
|
-
return getTypeStrategy({ ...finalOptions, url });
|
|
3257
|
+
return getTypeStrategy({ ...finalOptions, url }, player);
|
|
3131
3258
|
}
|
|
3132
3259
|
},
|
|
3133
3260
|
VePlayerLive
|
|
3134
3261
|
);
|
|
3262
|
+
if (player) {
|
|
3263
|
+
const RTMDegrade = (_b = (_a = player == null ? void 0 : player._player) == null ? void 0 : _a.config) == null ? void 0 : _b._RTMdegrade;
|
|
3264
|
+
if (RTMDegrade) {
|
|
3265
|
+
player.emit("degrade", {
|
|
3266
|
+
originRtmUrl: RTMDegrade._originRtmUrl,
|
|
3267
|
+
code: "NOT_SUPPORT",
|
|
3268
|
+
message: "not support rtm or h264",
|
|
3269
|
+
isRTMSupported: RTMDegrade._isRTMSupported,
|
|
3270
|
+
isRTMSupportCodec: RTMDegrade._isRTMSupportCodec
|
|
3271
|
+
});
|
|
3272
|
+
}
|
|
3273
|
+
}
|
|
3135
3274
|
return player;
|
|
3136
3275
|
}
|
|
3137
3276
|
var live = /* @__PURE__ */ Object.freeze({
|