@volcengine/veplayer 2.12.2-rc.0 → 2.13.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.
- package/esm/index.d.ts +0 -2
- package/esm/veplayer.biz.live.development.js +154 -8
- package/esm/veplayer.biz.live.production.js +1 -1
- package/esm/veplayer.d.ts +86 -75
- package/esm/veplayer.development.js +157 -15
- package/esm/veplayer.live.d.ts +86 -75
- package/esm/veplayer.live.development.js +157 -15
- package/esm/veplayer.live.production.js +3 -3
- package/esm/veplayer.production.js +3 -3
- package/esm/veplayer.vod.d.ts +0 -2
- package/esm/veplayer.vod.development.js +1 -7
- package/esm/veplayer.vod.production.js +2 -2
- package/package.json +1 -1
- package/umd/index.d.ts +0 -2
- package/umd/veplayer.biz.live.development.js +154 -8
- package/umd/veplayer.biz.live.production.js +1 -1
- package/umd/veplayer.d.ts +86 -75
- package/umd/veplayer.development.js +157 -15
- package/umd/veplayer.live.d.ts +86 -75
- package/umd/veplayer.live.development.js +157 -15
- package/umd/veplayer.live.production.js +1 -1
- package/umd/veplayer.production.js +1 -1
- package/umd/veplayer.vod.d.ts +0 -2
- package/umd/veplayer.vod.development.js +1 -7
- package/umd/veplayer.vod.production.js +1 -1
- package/veplayer.d.ts +86 -75
- package/veplayer.live.d.ts +86 -75
- package/veplayer.vod.d.ts +0 -2
package/esm/index.d.ts
CHANGED
|
@@ -5080,7 +5080,6 @@ declare namespace error {
|
|
|
5080
5080
|
declare namespace event {
|
|
5081
5081
|
const BaseEvents: {
|
|
5082
5082
|
SEI: string;
|
|
5083
|
-
SEI_IN_TIME: string;
|
|
5084
5083
|
PLAYER_CREATE_FINISH: string;
|
|
5085
5084
|
FALLBACK_ERROR: string;
|
|
5086
5085
|
FALLBACK: string;
|
|
@@ -5125,7 +5124,6 @@ declare namespace event {
|
|
|
5125
5124
|
};
|
|
5126
5125
|
const Events: {
|
|
5127
5126
|
SEI: string;
|
|
5128
|
-
SEI_IN_TIME: string;
|
|
5129
5127
|
PLAYER_CREATE_FINISH: string;
|
|
5130
5128
|
FALLBACK_ERROR: string;
|
|
5131
5129
|
FALLBACK: string;
|
|
@@ -26733,7 +26733,6 @@ function normalizeNumber(value, transform) {
|
|
|
26733
26733
|
return transform ? transform(value) : value.toString();
|
|
26734
26734
|
}
|
|
26735
26735
|
function getDefaultRow(data2) {
|
|
26736
|
-
var _a;
|
|
26737
26736
|
return {
|
|
26738
26737
|
rows: [
|
|
26739
26738
|
{
|
|
@@ -26774,7 +26773,10 @@ function getDefaultRow(data2) {
|
|
|
26774
26773
|
{
|
|
26775
26774
|
key: "bufferEnd",
|
|
26776
26775
|
labelTextKey: "BUFFER_END",
|
|
26777
|
-
value: normalizeNumber(
|
|
26776
|
+
value: normalizeNumber(
|
|
26777
|
+
data2.bufferEnd,
|
|
26778
|
+
(value) => Number(value.toFixed(2)).toString()
|
|
26779
|
+
)
|
|
26778
26780
|
},
|
|
26779
26781
|
{
|
|
26780
26782
|
key: "currentTime",
|
|
@@ -29239,8 +29241,6 @@ const licenseManager$1 = new LicenseManager();
|
|
|
29239
29241
|
const BaseEvents = {
|
|
29240
29242
|
// sei
|
|
29241
29243
|
SEI: "sei",
|
|
29242
|
-
// sei,在播放时间对齐到该 sei 的时间戳时抛出
|
|
29243
|
-
SEI_IN_TIME: "seiInTime",
|
|
29244
29244
|
// 播放器完成创建
|
|
29245
29245
|
PLAYER_CREATE_FINISH: "playerCreateFinish",
|
|
29246
29246
|
FALLBACK_ERROR: "fallbackError",
|
|
@@ -51017,6 +51017,79 @@ class LiveVeStrategy {
|
|
|
51017
51017
|
}
|
|
51018
51018
|
}
|
|
51019
51019
|
const liveVeStrategy = new LiveVeStrategy();
|
|
51020
|
+
const isNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
51021
|
+
const getTimestamp = (delaySEI, currentKey, legacyKey) => {
|
|
51022
|
+
const currentValue = delaySEI[currentKey];
|
|
51023
|
+
if (isNumber(currentValue)) {
|
|
51024
|
+
return currentValue;
|
|
51025
|
+
}
|
|
51026
|
+
const legacyValue = delaySEI[legacyKey];
|
|
51027
|
+
return isNumber(legacyValue) ? legacyValue : void 0;
|
|
51028
|
+
};
|
|
51029
|
+
const utf8ArrayToString = (array) => {
|
|
51030
|
+
let result = "";
|
|
51031
|
+
let index = 0;
|
|
51032
|
+
while (index < array.length) {
|
|
51033
|
+
const first = array[index++];
|
|
51034
|
+
if (first < 128) {
|
|
51035
|
+
result += String.fromCharCode(first);
|
|
51036
|
+
} else if (first < 224) {
|
|
51037
|
+
const second = array[index++];
|
|
51038
|
+
result += String.fromCharCode((first & 31) << 6 | second & 63);
|
|
51039
|
+
} else {
|
|
51040
|
+
const second = array[index++];
|
|
51041
|
+
const third = array[index++];
|
|
51042
|
+
result += String.fromCharCode(
|
|
51043
|
+
(first & 15) << 12 | (second & 63) << 6 | third & 63
|
|
51044
|
+
);
|
|
51045
|
+
}
|
|
51046
|
+
}
|
|
51047
|
+
return result;
|
|
51048
|
+
};
|
|
51049
|
+
const getSEIDelayStats = (sei, bufferTime = 0, now3 = Date.now()) => {
|
|
51050
|
+
if ((sei == null ? void 0 : sei.code) !== 100 || !sei.content) {
|
|
51051
|
+
return;
|
|
51052
|
+
}
|
|
51053
|
+
try {
|
|
51054
|
+
const rawSEI = utf8ArrayToString(sei.content);
|
|
51055
|
+
const jsonStart = rawSEI.indexOf("{");
|
|
51056
|
+
const jsonEnd = rawSEI.lastIndexOf("}");
|
|
51057
|
+
if (jsonStart < 0 || jsonEnd < jsonStart) {
|
|
51058
|
+
return;
|
|
51059
|
+
}
|
|
51060
|
+
const seiContent = JSON.parse(rawSEI.slice(jsonStart, jsonEnd + 1));
|
|
51061
|
+
const delaySEI = seiContent == null ? void 0 : seiContent.video_e2e_delay;
|
|
51062
|
+
if (!delaySEI || typeof delaySEI !== "object") {
|
|
51063
|
+
return;
|
|
51064
|
+
}
|
|
51065
|
+
const push3 = getTimestamp(delaySEI, "push_edge_ts", "push_node");
|
|
51066
|
+
const source = getTimestamp(delaySEI, "source_ts", "source_node");
|
|
51067
|
+
const cmafSource = getTimestamp(
|
|
51068
|
+
delaySEI,
|
|
51069
|
+
"cmaf_source_ts",
|
|
51070
|
+
"cmaf_source_node"
|
|
51071
|
+
);
|
|
51072
|
+
const hlsSource = getTimestamp(
|
|
51073
|
+
delaySEI,
|
|
51074
|
+
"hls_source_ts",
|
|
51075
|
+
"hls_source_node"
|
|
51076
|
+
);
|
|
51077
|
+
const pull = getTimestamp(delaySEI, "pull_edge_ts", "pull_node");
|
|
51078
|
+
const start = push3 ?? source;
|
|
51079
|
+
const end = pull ?? hlsSource ?? cmafSource;
|
|
51080
|
+
if (!isNumber(start) || !isNumber(end)) {
|
|
51081
|
+
return;
|
|
51082
|
+
}
|
|
51083
|
+
const delayS2S = end - start;
|
|
51084
|
+
const safeBufferTime = isNumber(bufferTime) ? Math.max(0, bufferTime) : 0;
|
|
51085
|
+
return {
|
|
51086
|
+
delay_s2s: delayS2S,
|
|
51087
|
+
delay_s2e: delayS2S + Math.max(0, now3 - end) + safeBufferTime
|
|
51088
|
+
};
|
|
51089
|
+
} catch (e2) {
|
|
51090
|
+
return;
|
|
51091
|
+
}
|
|
51092
|
+
};
|
|
51020
51093
|
const DEFAULT_PLUGINS = window["VePlayer"].DEFAULT_PLUGINS;
|
|
51021
51094
|
const VePlayerBase = window["VePlayer"].VePlayerBase;
|
|
51022
51095
|
const VeI18n = window["VePlayer"].VeI18n;
|
|
@@ -51059,6 +51132,22 @@ class VePlayerLive extends VePlayerBase {
|
|
|
51059
51132
|
* @hidden
|
|
51060
51133
|
*/
|
|
51061
51134
|
__publicField(this, "_protocolManager");
|
|
51135
|
+
__publicField(this, "_seiDelayStats", {});
|
|
51136
|
+
__publicField(this, "_resetSEIDelayStats", () => {
|
|
51137
|
+
this._seiDelayStats = {};
|
|
51138
|
+
});
|
|
51139
|
+
__publicField(this, "_handleSEI", (data2) => {
|
|
51140
|
+
const stats = getSEIDelayStats(data2 == null ? void 0 : data2.sei, this._getPlayerBufferTime());
|
|
51141
|
+
if (stats) {
|
|
51142
|
+
this._seiDelayStats = stats;
|
|
51143
|
+
}
|
|
51144
|
+
});
|
|
51145
|
+
this.on(Events$1.SEI, this._handleSEI);
|
|
51146
|
+
this.on(Events$1.URL_CHANGE, this._resetSEIDelayStats);
|
|
51147
|
+
this.on(Events$1.SOURCE_CHANGE, this._resetSEIDelayStats);
|
|
51148
|
+
this.on(Events$1.DEFINITION_CHANGE, this._resetSEIDelayStats);
|
|
51149
|
+
this.on(Events$1.REPLAY, this._resetSEIDelayStats);
|
|
51150
|
+
this.on(Events$1.FALLBACK, this._resetSEIDelayStats);
|
|
51062
51151
|
}
|
|
51063
51152
|
/** {zh}
|
|
51064
51153
|
* @brief 获取已经播放的时长,不包含暂停和等待时间,单位为秒。
|
|
@@ -51100,6 +51189,22 @@ class VePlayerLive extends VePlayerBase {
|
|
|
51100
51189
|
var _a, _b;
|
|
51101
51190
|
return (_b = (_a = this._player.plugins) == null ? void 0 : _a.hls) == null ? void 0 : _b.hls;
|
|
51102
51191
|
}
|
|
51192
|
+
/** {zh}
|
|
51193
|
+
* @hidden
|
|
51194
|
+
*/
|
|
51195
|
+
/** {en}
|
|
51196
|
+
* @hidden
|
|
51197
|
+
*/
|
|
51198
|
+
destroy() {
|
|
51199
|
+
this.off(Events$1.SEI, this._handleSEI);
|
|
51200
|
+
this.off(Events$1.URL_CHANGE, this._resetSEIDelayStats);
|
|
51201
|
+
this.off(Events$1.SOURCE_CHANGE, this._resetSEIDelayStats);
|
|
51202
|
+
this.off(Events$1.DEFINITION_CHANGE, this._resetSEIDelayStats);
|
|
51203
|
+
this.off(Events$1.REPLAY, this._resetSEIDelayStats);
|
|
51204
|
+
this.off(Events$1.FALLBACK, this._resetSEIDelayStats);
|
|
51205
|
+
this._resetSEIDelayStats();
|
|
51206
|
+
super.destroy();
|
|
51207
|
+
}
|
|
51103
51208
|
/** {zh}
|
|
51104
51209
|
* @brief 调用此方法开启直播日志上报。
|
|
51105
51210
|
*/
|
|
@@ -51236,7 +51341,8 @@ class VePlayerLive extends VePlayerBase {
|
|
|
51236
51341
|
*/
|
|
51237
51342
|
async getRTMStats() {
|
|
51238
51343
|
var _a, _b, _c;
|
|
51239
|
-
|
|
51344
|
+
const stats = await ((_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) == null ? void 0 : _c.getStatsSnapshoot());
|
|
51345
|
+
return this._mergeSEIDelayStats(stats);
|
|
51240
51346
|
}
|
|
51241
51347
|
/** {zh}
|
|
51242
51348
|
* @brief 获取 FLV 拉流的播放信息。
|
|
@@ -51247,7 +51353,8 @@ class VePlayerLive extends VePlayerBase {
|
|
|
51247
51353
|
*/
|
|
51248
51354
|
getFLVStats() {
|
|
51249
51355
|
var _a, _b, _c;
|
|
51250
|
-
|
|
51356
|
+
const stats = (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.flv) == null ? void 0 : _c.getStats();
|
|
51357
|
+
return this._mergeSEIDelayStats(stats);
|
|
51251
51358
|
}
|
|
51252
51359
|
/** {zh}
|
|
51253
51360
|
* @brief 获取 HLS 拉流的播放信息。
|
|
@@ -51259,8 +51366,9 @@ class VePlayerLive extends VePlayerBase {
|
|
|
51259
51366
|
* @hidden
|
|
51260
51367
|
*/
|
|
51261
51368
|
getHLSStats() {
|
|
51262
|
-
var _a, _b, _c;
|
|
51263
|
-
|
|
51369
|
+
var _a, _b, _c, _d;
|
|
51370
|
+
const stats = ((_d = (_c = (_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.hls) == null ? void 0 : _c.getStats) == null ? void 0 : _d.call(_c)) ?? {};
|
|
51371
|
+
return this._mergeSEIDelayStats(stats);
|
|
51264
51372
|
}
|
|
51265
51373
|
/** {en}
|
|
51266
51374
|
* @brief This method is used to update the playlist, supporting updates to source, resolution, and related information.
|
|
@@ -51288,6 +51396,40 @@ class VePlayerLive extends VePlayerBase {
|
|
|
51288
51396
|
}
|
|
51289
51397
|
return super.updatePlaylist(playlist, target);
|
|
51290
51398
|
}
|
|
51399
|
+
_getPlayerBufferTime() {
|
|
51400
|
+
var _a, _b, _c, _d, _e2;
|
|
51401
|
+
try {
|
|
51402
|
+
const rtm = ((_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.rts) ?? ((_d = (_c = this._player) == null ? void 0 : _c.plugins) == null ? void 0 : _d.rtm);
|
|
51403
|
+
if (rtm) {
|
|
51404
|
+
const jitterBufferDelay = rtm.jitterBufferDelay;
|
|
51405
|
+
if (Number.isFinite(jitterBufferDelay) && jitterBufferDelay >= 0) {
|
|
51406
|
+
return jitterBufferDelay;
|
|
51407
|
+
}
|
|
51408
|
+
}
|
|
51409
|
+
} catch (e2) {
|
|
51410
|
+
}
|
|
51411
|
+
const video = (_e2 = this._player) == null ? void 0 : _e2.video;
|
|
51412
|
+
const buffered = video == null ? void 0 : video.buffered;
|
|
51413
|
+
if (!video || !(buffered == null ? void 0 : buffered.length)) {
|
|
51414
|
+
return 0;
|
|
51415
|
+
}
|
|
51416
|
+
try {
|
|
51417
|
+
return Math.trunc(
|
|
51418
|
+
(buffered.end(buffered.length - 1) - video.currentTime) * 1e3
|
|
51419
|
+
);
|
|
51420
|
+
} catch (e2) {
|
|
51421
|
+
return 0;
|
|
51422
|
+
}
|
|
51423
|
+
}
|
|
51424
|
+
_mergeSEIDelayStats(stats) {
|
|
51425
|
+
if (!stats) {
|
|
51426
|
+
return stats;
|
|
51427
|
+
}
|
|
51428
|
+
return {
|
|
51429
|
+
...stats,
|
|
51430
|
+
...this._seiDelayStats
|
|
51431
|
+
};
|
|
51432
|
+
}
|
|
51291
51433
|
}
|
|
51292
51434
|
async function createLivePlayer(options) {
|
|
51293
51435
|
var _a, _b, _c, _d, _e2, _f, _g, _h, _i2, _j, _k;
|
|
@@ -51320,6 +51462,10 @@ async function createLivePlayer(options) {
|
|
|
51320
51462
|
playerOptions,
|
|
51321
51463
|
recommendation
|
|
51322
51464
|
);
|
|
51465
|
+
finalOptions.rtm = {
|
|
51466
|
+
enableSei: true,
|
|
51467
|
+
...finalOptions.rtm
|
|
51468
|
+
};
|
|
51323
51469
|
await liveLicenseManager.create();
|
|
51324
51470
|
const licenseFatalError = liveLicenseManager.getLicenseFatalError();
|
|
51325
51471
|
const protocolManager = await ProtocolManager.create(finalOptions);
|