@volcengine/veplayer 1.6.4 → 2.0.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 +3 -45
- package/esm/index.d.ts +1405 -0
- package/esm/veplayer.biz.live.development.css +41 -0
- package/esm/veplayer.biz.live.development.js +3157 -0
- package/esm/veplayer.biz.live.production.css +1 -0
- package/esm/veplayer.biz.live.production.js +2 -0
- package/esm/veplayer.biz.vod.development.js +13 -0
- package/esm/veplayer.biz.vod.production.js +2 -0
- package/esm/veplayer.d.ts +3071 -0
- package/esm/veplayer.development.css +743 -0
- package/esm/veplayer.development.js +21023 -0
- package/esm/veplayer.live.d.ts +3074 -0
- package/esm/veplayer.live.development.css +743 -0
- package/esm/veplayer.live.development.js +21022 -0
- package/esm/veplayer.live.production.css +1 -0
- package/esm/veplayer.live.production.js +11 -0
- package/esm/veplayer.production.css +1 -0
- package/esm/veplayer.production.js +11 -0
- package/esm/veplayer.vod.d.ts +1405 -0
- package/esm/veplayer.vod.development.css +702 -0
- package/esm/veplayer.vod.development.js +13104 -0
- package/esm/veplayer.vod.production.css +1 -0
- package/esm/veplayer.vod.production.js +11 -0
- package/package.json +78 -6
- package/umd/index.d.ts +1405 -0
- package/umd/veplayer.biz.live.development.css +41 -0
- package/umd/veplayer.biz.live.development.js +3169 -0
- package/umd/veplayer.biz.live.production.css +1 -0
- package/umd/veplayer.biz.live.production.js +1 -0
- package/umd/veplayer.biz.vod.development.js +29 -0
- package/umd/veplayer.biz.vod.production.js +1 -0
- package/umd/veplayer.d.ts +3071 -0
- package/umd/veplayer.development.css +743 -0
- package/umd/veplayer.development.js +21026 -0
- package/umd/veplayer.live.d.ts +3074 -0
- package/umd/veplayer.live.development.css +743 -0
- package/umd/veplayer.live.development.js +21034 -0
- package/umd/veplayer.live.production.css +1 -0
- package/umd/veplayer.live.production.js +1 -0
- package/umd/veplayer.production.css +1 -0
- package/umd/veplayer.production.js +1 -0
- package/umd/veplayer.vod.d.ts +1405 -0
- package/umd/veplayer.vod.development.css +702 -0
- package/umd/veplayer.vod.development.js +13119 -0
- package/umd/veplayer.vod.production.css +1 -0
- package/umd/veplayer.vod.production.js +1 -0
- package/index.d.ts +0 -3256
- package/index.min.css +0 -1
- package/index.min.js +0 -2
|
@@ -0,0 +1,3157 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
const error = window["VePlayer"].error;
|
|
8
|
+
const { VeError } = error;
|
|
9
|
+
var LiveErrorCode = /* @__PURE__ */ ((LiveErrorCode2) => {
|
|
10
|
+
LiveErrorCode2[LiveErrorCode2["INVALID_PARAMETER"] = 200] = "INVALID_PARAMETER";
|
|
11
|
+
return LiveErrorCode2;
|
|
12
|
+
})(LiveErrorCode || {});
|
|
13
|
+
error.Level;
|
|
14
|
+
const ErrorCode = {
|
|
15
|
+
...LiveErrorCode,
|
|
16
|
+
...error.ErrorCode
|
|
17
|
+
};
|
|
18
|
+
const ERRORS = {
|
|
19
|
+
...error.ERROR_INFO,
|
|
20
|
+
[
|
|
21
|
+
200
|
|
22
|
+
/* INVALID_PARAMETER */
|
|
23
|
+
]: {
|
|
24
|
+
messageTextKey: "INVALID_PARAMETER",
|
|
25
|
+
level: error.Level.Fatal
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
function create(errorCode, i18n) {
|
|
29
|
+
return new VeError(ERRORS[errorCode], i18n);
|
|
30
|
+
}
|
|
31
|
+
const strategy$1 = window["VePlayer"].strategy;
|
|
32
|
+
const util$3 = window["VePlayer"].util;
|
|
33
|
+
const DynamicModule$1 = window["VePlayer"].DynamicModule;
|
|
34
|
+
const load$1 = window["VePlayer"].load;
|
|
35
|
+
const Codec$1 = window["VePlayer"].Codec;
|
|
36
|
+
const Sniffer$2 = window["VePlayer"].Sniffer;
|
|
37
|
+
const rtmStrategy = {
|
|
38
|
+
options: {},
|
|
39
|
+
module: DynamicModule$1.PluginRtm
|
|
40
|
+
};
|
|
41
|
+
const getRtmStrategy = async (options) => {
|
|
42
|
+
var _a;
|
|
43
|
+
let backupStrategy;
|
|
44
|
+
const { fallbackUrl, ...ret } = options.rtm || {};
|
|
45
|
+
const backupType = fallbackUrl && util$3.getStreamType(fallbackUrl);
|
|
46
|
+
if (backupType === "flv" && util$3.isMseSupported(Codec$1.H264)) {
|
|
47
|
+
backupStrategy = strategy$1.createFlvMseStrategy(options);
|
|
48
|
+
} 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)) {
|
|
49
|
+
backupStrategy = strategy$1.createHlsMseStrategy(options);
|
|
50
|
+
}
|
|
51
|
+
const [rtmCdn, backupCdn] = await Promise.all([
|
|
52
|
+
load$1(rtmStrategy.module).catch(() => void 0),
|
|
53
|
+
backupStrategy && load$1(backupStrategy.module).catch(() => void 0)
|
|
54
|
+
]);
|
|
55
|
+
return {
|
|
56
|
+
options: {
|
|
57
|
+
...(backupStrategy == null ? void 0 : backupStrategy.options) || {},
|
|
58
|
+
rts: {
|
|
59
|
+
retryCount: 0,
|
|
60
|
+
...ret,
|
|
61
|
+
backupURL: fallbackUrl,
|
|
62
|
+
backupConstruct: backupCdn
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
plugins: rtmCdn ? [rtmCdn] : []
|
|
66
|
+
};
|
|
67
|
+
};
|
|
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", options) => {
|
|
77
|
+
const Rtm = await load$1(DynamicModule$1.PluginRtm);
|
|
78
|
+
if (codec === "h264")
|
|
79
|
+
return Rtm.isSupportedH264(options == null ? void 0 : options.targetProfileLevel);
|
|
80
|
+
};
|
|
81
|
+
const util$2 = window["VePlayer"].util;
|
|
82
|
+
const strategy = window["VePlayer"].strategy;
|
|
83
|
+
const getTypeStrategy = async (options) => {
|
|
84
|
+
const type = options.url ? util$2.getStreamType(options.url) : "";
|
|
85
|
+
if (!type || type === "unknown") {
|
|
86
|
+
return { options: {}, plugins: [] };
|
|
87
|
+
}
|
|
88
|
+
if (type === "rtm") {
|
|
89
|
+
return await getRtmStrategy(options);
|
|
90
|
+
}
|
|
91
|
+
if (type === "flv") {
|
|
92
|
+
return await strategy.getFlvStrategy(options);
|
|
93
|
+
}
|
|
94
|
+
if (type === "hls") {
|
|
95
|
+
return await strategy.getHlsStrategy(options);
|
|
96
|
+
}
|
|
97
|
+
return { options: {}, plugins: [] };
|
|
98
|
+
};
|
|
99
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
100
|
+
function getDefaultExportFromCjs(x2) {
|
|
101
|
+
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
|
|
102
|
+
}
|
|
103
|
+
var FUNC_ERROR_TEXT = "Expected a function";
|
|
104
|
+
var NAN = 0 / 0;
|
|
105
|
+
var symbolTag = "[object Symbol]";
|
|
106
|
+
var reTrim = /^\s+|\s+$/g;
|
|
107
|
+
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
108
|
+
var reIsBinary = /^0b[01]+$/i;
|
|
109
|
+
var reIsOctal = /^0o[0-7]+$/i;
|
|
110
|
+
var freeParseInt = parseInt;
|
|
111
|
+
var freeGlobal = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
112
|
+
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
113
|
+
var root = freeGlobal || freeSelf || Function("return this")();
|
|
114
|
+
var objectProto = Object.prototype;
|
|
115
|
+
var objectToString = objectProto.toString;
|
|
116
|
+
var nativeMax = Math.max, nativeMin = Math.min;
|
|
117
|
+
var now = function() {
|
|
118
|
+
return root.Date.now();
|
|
119
|
+
};
|
|
120
|
+
function debounce(func, wait, options) {
|
|
121
|
+
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
122
|
+
if (typeof func != "function") {
|
|
123
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
124
|
+
}
|
|
125
|
+
wait = toNumber(wait) || 0;
|
|
126
|
+
if (isObject(options)) {
|
|
127
|
+
leading = !!options.leading;
|
|
128
|
+
maxing = "maxWait" in options;
|
|
129
|
+
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
130
|
+
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
131
|
+
}
|
|
132
|
+
function invokeFunc(time) {
|
|
133
|
+
var args = lastArgs, thisArg = lastThis;
|
|
134
|
+
lastArgs = lastThis = void 0;
|
|
135
|
+
lastInvokeTime = time;
|
|
136
|
+
result = func.apply(thisArg, args);
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
function leadingEdge(time) {
|
|
140
|
+
lastInvokeTime = time;
|
|
141
|
+
timerId = setTimeout(timerExpired, wait);
|
|
142
|
+
return leading ? invokeFunc(time) : result;
|
|
143
|
+
}
|
|
144
|
+
function remainingWait(time) {
|
|
145
|
+
var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, result2 = wait - timeSinceLastCall;
|
|
146
|
+
return maxing ? nativeMin(result2, maxWait - timeSinceLastInvoke) : result2;
|
|
147
|
+
}
|
|
148
|
+
function shouldInvoke(time) {
|
|
149
|
+
var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
|
|
150
|
+
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
|
|
151
|
+
}
|
|
152
|
+
function timerExpired() {
|
|
153
|
+
var time = now();
|
|
154
|
+
if (shouldInvoke(time)) {
|
|
155
|
+
return trailingEdge(time);
|
|
156
|
+
}
|
|
157
|
+
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
158
|
+
}
|
|
159
|
+
function trailingEdge(time) {
|
|
160
|
+
timerId = void 0;
|
|
161
|
+
if (trailing && lastArgs) {
|
|
162
|
+
return invokeFunc(time);
|
|
163
|
+
}
|
|
164
|
+
lastArgs = lastThis = void 0;
|
|
165
|
+
return result;
|
|
166
|
+
}
|
|
167
|
+
function cancel() {
|
|
168
|
+
if (timerId !== void 0) {
|
|
169
|
+
clearTimeout(timerId);
|
|
170
|
+
}
|
|
171
|
+
lastInvokeTime = 0;
|
|
172
|
+
lastArgs = lastCallTime = lastThis = timerId = void 0;
|
|
173
|
+
}
|
|
174
|
+
function flush() {
|
|
175
|
+
return timerId === void 0 ? result : trailingEdge(now());
|
|
176
|
+
}
|
|
177
|
+
function debounced() {
|
|
178
|
+
var time = now(), isInvoking = shouldInvoke(time);
|
|
179
|
+
lastArgs = arguments;
|
|
180
|
+
lastThis = this;
|
|
181
|
+
lastCallTime = time;
|
|
182
|
+
if (isInvoking) {
|
|
183
|
+
if (timerId === void 0) {
|
|
184
|
+
return leadingEdge(lastCallTime);
|
|
185
|
+
}
|
|
186
|
+
if (maxing) {
|
|
187
|
+
timerId = setTimeout(timerExpired, wait);
|
|
188
|
+
return invokeFunc(lastCallTime);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (timerId === void 0) {
|
|
192
|
+
timerId = setTimeout(timerExpired, wait);
|
|
193
|
+
}
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
debounced.cancel = cancel;
|
|
197
|
+
debounced.flush = flush;
|
|
198
|
+
return debounced;
|
|
199
|
+
}
|
|
200
|
+
function isObject(value) {
|
|
201
|
+
var type = typeof value;
|
|
202
|
+
return !!value && (type == "object" || type == "function");
|
|
203
|
+
}
|
|
204
|
+
function isObjectLike(value) {
|
|
205
|
+
return !!value && typeof value == "object";
|
|
206
|
+
}
|
|
207
|
+
function isSymbol(value) {
|
|
208
|
+
return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
|
|
209
|
+
}
|
|
210
|
+
function toNumber(value) {
|
|
211
|
+
if (typeof value == "number") {
|
|
212
|
+
return value;
|
|
213
|
+
}
|
|
214
|
+
if (isSymbol(value)) {
|
|
215
|
+
return NAN;
|
|
216
|
+
}
|
|
217
|
+
if (isObject(value)) {
|
|
218
|
+
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
219
|
+
value = isObject(other) ? other + "" : other;
|
|
220
|
+
}
|
|
221
|
+
if (typeof value != "string") {
|
|
222
|
+
return value === 0 ? value : +value;
|
|
223
|
+
}
|
|
224
|
+
value = value.replace(reTrim, "");
|
|
225
|
+
var isBinary = reIsBinary.test(value);
|
|
226
|
+
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
|
227
|
+
}
|
|
228
|
+
var lodash_debounce = debounce;
|
|
229
|
+
var debounce$1 = /* @__PURE__ */ getDefaultExportFromCjs(lodash_debounce);
|
|
230
|
+
const event = window["VePlayer"].event;
|
|
231
|
+
const Events = {
|
|
232
|
+
...event.Events,
|
|
233
|
+
// 直播的Events
|
|
234
|
+
TIME_SHIFT_CHANGE: "time_shift_change",
|
|
235
|
+
// 切换时移状态
|
|
236
|
+
REFRESH_CLICK: "refresh_click"
|
|
237
|
+
// 触发刷新
|
|
238
|
+
};
|
|
239
|
+
function RefreshIcon() {
|
|
240
|
+
return new DOMParser().parseFromString('<svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M10 2.488a7.48 7.48 0 00-4.154 1.253.908.908 0 101.005 1.512 5.695 5.695 0 018.844 4.746h-.908a.33.33 0 00-.264.528l1.816 2.422a.33.33 0 00.529 0l1.815-2.422A.33.33 0 0018.42 10h-.908A7.511 7.511 0 0010 2.49zM2.489 10a7.511 7.511 0 0011.665 6.26.908.908 0 00-1.005-1.513A5.695 5.695 0 014.305 10h.908a.33.33 0 00.264-.528L3.66 7.05a.33.33 0 00-.528 0L1.317 9.47a.33.33 0 00.264.53h.908z" fill="#fff"/></svg>', "image/svg+xml").firstChild;
|
|
241
|
+
}
|
|
242
|
+
var refresh = "";
|
|
243
|
+
const Plugin$3 = window["VePlayer"].Plugin;
|
|
244
|
+
const Sniffer$1 = window["VePlayer"].Sniffer;
|
|
245
|
+
const XGEvents = window["VePlayer"].XGEvents;
|
|
246
|
+
const { POSITIONS: POSITIONS$1 } = Plugin$3;
|
|
247
|
+
class Refresh extends Plugin$3 {
|
|
248
|
+
static get pluginName() {
|
|
249
|
+
return "refresh";
|
|
250
|
+
}
|
|
251
|
+
static get defaultConfig() {
|
|
252
|
+
return {
|
|
253
|
+
position: POSITIONS$1.CONTROLS_LEFT,
|
|
254
|
+
index: 1,
|
|
255
|
+
disable: false
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
afterCreate() {
|
|
259
|
+
if (this.config.disable) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
this.appendChild(".xgplayer-icon", this.icons.refresh);
|
|
263
|
+
this._initEvents();
|
|
264
|
+
}
|
|
265
|
+
registerIcons() {
|
|
266
|
+
return {
|
|
267
|
+
refresh: {
|
|
268
|
+
icon: RefreshIcon,
|
|
269
|
+
class: "xgplayer-refresh-svg"
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
destroy() {
|
|
274
|
+
this.unbind(["touchend", "click"], this._handleRefresh);
|
|
275
|
+
}
|
|
276
|
+
render() {
|
|
277
|
+
const i18nManager = this.player.config.i18nManager;
|
|
278
|
+
return `
|
|
279
|
+
<xg-icon class="veplayer-refresh">
|
|
280
|
+
<div class="xgplayer-icon">
|
|
281
|
+
</div>
|
|
282
|
+
<div class="xg-tips" lang-key="refresh">${i18nManager.getText(
|
|
283
|
+
"REFRESH"
|
|
284
|
+
)}</div>
|
|
285
|
+
</xg-icon>
|
|
286
|
+
`;
|
|
287
|
+
}
|
|
288
|
+
_handleRefresh(e3) {
|
|
289
|
+
var _a, _b, _c;
|
|
290
|
+
const { player } = this;
|
|
291
|
+
if (!player)
|
|
292
|
+
return;
|
|
293
|
+
e3.preventDefault();
|
|
294
|
+
e3.stopPropagation();
|
|
295
|
+
player.addClass("xgplayer-is-enter");
|
|
296
|
+
player.pause();
|
|
297
|
+
if (player) {
|
|
298
|
+
player.emit(Events.REFRESH_CLICK);
|
|
299
|
+
(_c = (_b = (_a = this.player) == null ? void 0 : _a.config) == null ? void 0 : _b.veplayer) == null ? void 0 : _c.retry();
|
|
300
|
+
}
|
|
301
|
+
player.once(XGEvents.CANPLAY, () => {
|
|
302
|
+
player.removeClass("xgplayer-is-enter");
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
_initEvents() {
|
|
306
|
+
this._handleRefresh = debounce$1(this._handleRefresh.bind(this), 200);
|
|
307
|
+
const event2 = Sniffer$1.device === "mobile" ? "touchend" : "click";
|
|
308
|
+
this.bind(event2, this._handleRefresh);
|
|
309
|
+
this.show();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function _defineProperties(target, props) {
|
|
313
|
+
for (var i2 = 0; i2 < props.length; i2++) {
|
|
314
|
+
var descriptor = props[i2];
|
|
315
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
316
|
+
descriptor.configurable = true;
|
|
317
|
+
if ("value" in descriptor)
|
|
318
|
+
descriptor.writable = true;
|
|
319
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
323
|
+
if (protoProps)
|
|
324
|
+
_defineProperties(Constructor.prototype, protoProps);
|
|
325
|
+
if (staticProps)
|
|
326
|
+
_defineProperties(Constructor, staticProps);
|
|
327
|
+
return Constructor;
|
|
328
|
+
}
|
|
329
|
+
function _defineProperty(obj, key, value) {
|
|
330
|
+
if (key in obj) {
|
|
331
|
+
Object.defineProperty(obj, key, {
|
|
332
|
+
value,
|
|
333
|
+
enumerable: true,
|
|
334
|
+
configurable: true,
|
|
335
|
+
writable: true
|
|
336
|
+
});
|
|
337
|
+
} else {
|
|
338
|
+
obj[key] = value;
|
|
339
|
+
}
|
|
340
|
+
return obj;
|
|
341
|
+
}
|
|
342
|
+
function ownKeys(object, enumerableOnly) {
|
|
343
|
+
var keys = Object.keys(object);
|
|
344
|
+
if (Object.getOwnPropertySymbols) {
|
|
345
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
346
|
+
if (enumerableOnly)
|
|
347
|
+
symbols = symbols.filter(function(sym) {
|
|
348
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
349
|
+
});
|
|
350
|
+
keys.push.apply(keys, symbols);
|
|
351
|
+
}
|
|
352
|
+
return keys;
|
|
353
|
+
}
|
|
354
|
+
function _objectSpread2(target) {
|
|
355
|
+
for (var i2 = 1; i2 < arguments.length; i2++) {
|
|
356
|
+
var source = arguments[i2] != null ? arguments[i2] : {};
|
|
357
|
+
if (i2 % 2) {
|
|
358
|
+
ownKeys(Object(source), true).forEach(function(key) {
|
|
359
|
+
_defineProperty(target, key, source[key]);
|
|
360
|
+
});
|
|
361
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
362
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
363
|
+
} else {
|
|
364
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
365
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return target;
|
|
370
|
+
}
|
|
371
|
+
var device_id_key = "xgplayer_device_id";
|
|
372
|
+
var user_id_key = "xgplayer_user_id";
|
|
373
|
+
var getCookie = function getCookie2(key) {
|
|
374
|
+
if (!document.cookie) {
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
var cookieKVPairs = document.cookie.split(";");
|
|
378
|
+
for (var i2 = 0, len = cookieKVPairs.length; i2 < len; i2++) {
|
|
379
|
+
var pair = cookieKVPairs[i2];
|
|
380
|
+
if (cookieKVPairs[i2].indexOf(key) >= 0) {
|
|
381
|
+
var value = pair.split("=")[1];
|
|
382
|
+
return value || null;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
var genRandomID$1 = function genRandomID(length) {
|
|
387
|
+
return String(Math.floor(Math.random() * Math.pow(10, length)));
|
|
388
|
+
};
|
|
389
|
+
var getDeviceID$1 = function getDeviceID() {
|
|
390
|
+
var did = getCookie(device_id_key);
|
|
391
|
+
if (did) {
|
|
392
|
+
return did;
|
|
393
|
+
}
|
|
394
|
+
var newDid = genRandomID$1(11);
|
|
395
|
+
document.cookie = device_id_key + "=" + newDid + ";max-age=31536000;path=/";
|
|
396
|
+
return newDid;
|
|
397
|
+
};
|
|
398
|
+
var getUserId$1 = function getUserId() {
|
|
399
|
+
var uid = getCookie(user_id_key);
|
|
400
|
+
if (uid) {
|
|
401
|
+
return uid;
|
|
402
|
+
}
|
|
403
|
+
var newUid = genRandomID$1(12);
|
|
404
|
+
document.cookie = user_id_key + "=" + newUid + ";max-age=31536000;path=/";
|
|
405
|
+
return newUid;
|
|
406
|
+
};
|
|
407
|
+
var getLogId = function getLogId2() {
|
|
408
|
+
return genRandomID$1(12);
|
|
409
|
+
};
|
|
410
|
+
function getBrowser() {
|
|
411
|
+
var UserAgent = navigator.userAgent.toLowerCase();
|
|
412
|
+
var browserInfo = {};
|
|
413
|
+
var browserArray = {
|
|
414
|
+
IE: window.ActiveXObject || "ActiveXObject" in window,
|
|
415
|
+
// IE
|
|
416
|
+
Chrome: UserAgent.indexOf("chrome") > -1 && UserAgent.indexOf("safari") > -1,
|
|
417
|
+
// Chrome浏览器
|
|
418
|
+
Firefox: UserAgent.indexOf("firefox") > -1,
|
|
419
|
+
// 火狐浏览器
|
|
420
|
+
Opera: UserAgent.indexOf("opera") > -1,
|
|
421
|
+
// Opera浏览器
|
|
422
|
+
Safari: UserAgent.indexOf("safari") > -1 && UserAgent.indexOf("chrome") == -1,
|
|
423
|
+
// safari浏览器
|
|
424
|
+
Edge: UserAgent.indexOf("edge") > -1,
|
|
425
|
+
// Edge浏览器
|
|
426
|
+
QQBrowser: /qqbrowser/.test(UserAgent),
|
|
427
|
+
// qq浏览器
|
|
428
|
+
WeixinBrowser: /MicroMessenger/i.test(UserAgent)
|
|
429
|
+
// 微信浏览器
|
|
430
|
+
};
|
|
431
|
+
for (var i2 in browserArray) {
|
|
432
|
+
if (browserArray[i2]) {
|
|
433
|
+
var versions = "";
|
|
434
|
+
if (i2 === "IE") {
|
|
435
|
+
versions = UserAgent.match(/(msie\s|trident.*rv:)([\w.]+)/)[2];
|
|
436
|
+
} else if (i2 === "Chrome") {
|
|
437
|
+
for (var mt in navigator.mimeTypes) {
|
|
438
|
+
if (navigator.mimeTypes[mt]["type"] === "application/360softmgrplugin") {
|
|
439
|
+
i2 = "360";
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
var match = UserAgent.match(/chrome\/([\d.]+)/);
|
|
443
|
+
versions = match ? match[1] : "-1";
|
|
444
|
+
} else if (i2 === "Firefox") {
|
|
445
|
+
var _match = UserAgent.match(/firefox\/([\d.]+)/);
|
|
446
|
+
versions = _match ? _match[1] : "-1";
|
|
447
|
+
} else if (i2 === "Opera") {
|
|
448
|
+
var _match2 = UserAgent.match(/opera\/([\d.]+)/);
|
|
449
|
+
versions = _match2 ? _match2[1] : "-1";
|
|
450
|
+
} else if (i2 === "Safari") {
|
|
451
|
+
var _match3 = UserAgent.match(/version\/([\d.]+)/);
|
|
452
|
+
versions = _match3 ? _match3[1] : "-1";
|
|
453
|
+
} else if (i2 === "Edge") {
|
|
454
|
+
var _match4 = UserAgent.match(/edge\/([\d.]+)/);
|
|
455
|
+
versions = _match4 ? _match4[1] : "-1";
|
|
456
|
+
} else if (i2 === "QQBrowser") {
|
|
457
|
+
var _match5 = UserAgent.match(/qqbrowser\/([\d.]+)/);
|
|
458
|
+
versions = _match5 ? _match5[1] : "-1";
|
|
459
|
+
}
|
|
460
|
+
browserInfo.type = i2;
|
|
461
|
+
browserInfo.versions = parseInt(versions);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return browserInfo;
|
|
465
|
+
}
|
|
466
|
+
var sniffer = {
|
|
467
|
+
get device() {
|
|
468
|
+
var r2 = sniffer.os;
|
|
469
|
+
return r2.isPc ? "pc" : "mobile";
|
|
470
|
+
},
|
|
471
|
+
get browser() {
|
|
472
|
+
var _getBrowser = getBrowser(), type = _getBrowser.type, versions = _getBrowser.versions;
|
|
473
|
+
return type + "_" + versions;
|
|
474
|
+
},
|
|
475
|
+
get os() {
|
|
476
|
+
var ua = navigator.userAgent;
|
|
477
|
+
navigator.platform.toLowerCase();
|
|
478
|
+
var isWindowsPhone = /(?:Windows Phone)/.test(ua);
|
|
479
|
+
var isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone;
|
|
480
|
+
var isAndroid = /(?:Android)/.test(ua);
|
|
481
|
+
var isFireFox = /(?:Firefox)/.test(ua);
|
|
482
|
+
var isTablet = /(?:iPad|PlayBook)/.test(ua) || isAndroid && !/(?:Mobile)/.test(ua) || isFireFox && /(?:Tablet)/.test(ua);
|
|
483
|
+
var isPhone = /(?:iPhone)/.test(ua) && !isTablet;
|
|
484
|
+
var isPc = !isPhone && !isAndroid && !isSymbian && !isTablet;
|
|
485
|
+
return {
|
|
486
|
+
isTablet,
|
|
487
|
+
isPhone,
|
|
488
|
+
isAndroid,
|
|
489
|
+
isPc,
|
|
490
|
+
isSymbian,
|
|
491
|
+
isWindowsPhone,
|
|
492
|
+
isFireFox
|
|
493
|
+
};
|
|
494
|
+
},
|
|
495
|
+
get operation_os() {
|
|
496
|
+
var userAgent = navigator.userAgent;
|
|
497
|
+
var clientOpts = [{
|
|
498
|
+
s: "windows",
|
|
499
|
+
r: /(Windows 10.0|Windows NT 10.0|Windows NT 10.1|Windows 8.1|Windows NT 6.3|Windows 8|Windows NT 6.2|Windows 7|Windows NT 6.1)/
|
|
500
|
+
}, {
|
|
501
|
+
s: "android",
|
|
502
|
+
r: /Android/
|
|
503
|
+
}, {
|
|
504
|
+
s: "linux",
|
|
505
|
+
r: /(Linux|X11)/
|
|
506
|
+
}, {
|
|
507
|
+
s: "ios",
|
|
508
|
+
r: /(iPhone|iPad|iPod)/
|
|
509
|
+
}, {
|
|
510
|
+
s: "mac",
|
|
511
|
+
r: /Mac OS X/
|
|
512
|
+
}, {
|
|
513
|
+
s: "mac",
|
|
514
|
+
r: /(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/
|
|
515
|
+
}];
|
|
516
|
+
for (var i2 = 0; i2 < clientOpts.length; i2++) {
|
|
517
|
+
var cs = clientOpts[i2];
|
|
518
|
+
if (cs.r.test(userAgent)) {
|
|
519
|
+
return cs.s;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
return "unknown";
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
function getCurrentTime() {
|
|
526
|
+
return Date.now();
|
|
527
|
+
}
|
|
528
|
+
function getPlayFormat(url) {
|
|
529
|
+
var unKnownVal = "unknown";
|
|
530
|
+
if (typeof url !== "string")
|
|
531
|
+
return unKnownVal;
|
|
532
|
+
if (url.indexOf(".flv") > -1)
|
|
533
|
+
return "flv";
|
|
534
|
+
if (url.indexOf(".m3u8") > -1)
|
|
535
|
+
return "m3u8";
|
|
536
|
+
if (url.indexOf(".mp4") > -1)
|
|
537
|
+
return "mp4";
|
|
538
|
+
if (url.indexOf(".sdp") > -1)
|
|
539
|
+
return "rts";
|
|
540
|
+
return unKnownVal;
|
|
541
|
+
}
|
|
542
|
+
function isCodecSupport(codec) {
|
|
543
|
+
return typeof MediaSource !== "undefined" ? +MediaSource.isTypeSupported("video/mp4; codecs=" + codec) : 0;
|
|
544
|
+
}
|
|
545
|
+
function getUrlQuery(url, key) {
|
|
546
|
+
var x2 = new URLSearchParams(url.split("?")[1]);
|
|
547
|
+
return x2.get(key);
|
|
548
|
+
}
|
|
549
|
+
function getDeviceInfo() {
|
|
550
|
+
var res = {
|
|
551
|
+
cpu_core_number: -1,
|
|
552
|
+
memory_usage: -1,
|
|
553
|
+
network_downlink: -1
|
|
554
|
+
};
|
|
555
|
+
try {
|
|
556
|
+
res.cpu_core_number = navigator.hardwareConcurrency || -1;
|
|
557
|
+
res.memory_usage = navigator.deviceMemory || -1;
|
|
558
|
+
res.network_downlink = navigator.connection && navigator.connection.downlink;
|
|
559
|
+
if (res.network_downlink == void 0) {
|
|
560
|
+
res.network_downlink = -1;
|
|
561
|
+
}
|
|
562
|
+
} catch (error2) {
|
|
563
|
+
}
|
|
564
|
+
return res;
|
|
565
|
+
}
|
|
566
|
+
function getPlayerCore(player) {
|
|
567
|
+
if (player.plugins) {
|
|
568
|
+
if (player.plugins.flv) {
|
|
569
|
+
return player.plugins.flv;
|
|
570
|
+
} else if (player.plugins.hls) {
|
|
571
|
+
return player.plugins.hls;
|
|
572
|
+
} else if (player.plugins.rts) {
|
|
573
|
+
return player.plugins.rts;
|
|
574
|
+
} else if (player.plugins.flvlive) {
|
|
575
|
+
return player.plugins.flvlive;
|
|
576
|
+
} else if (player.plugins.hlslive) {
|
|
577
|
+
return player.plugins.hlslive;
|
|
578
|
+
} else if (player.plugins.hlsvod) {
|
|
579
|
+
return player.plugins.hlsvod;
|
|
580
|
+
} else if (player.plugins.hlslivemobile) {
|
|
581
|
+
return player.plugins.hlslivemobile;
|
|
582
|
+
} else if (player.plugins.flvlivemobile) {
|
|
583
|
+
return player.plugins.flvlivemobile;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
return player.newHls || player.newFlv || player.__core__ || player.flv;
|
|
587
|
+
}
|
|
588
|
+
function getDefaultOptions(options) {
|
|
589
|
+
return {
|
|
590
|
+
device_id: options.device_id || getDeviceID$1(),
|
|
591
|
+
user_id: options.user_id || getUserId$1(),
|
|
592
|
+
error_report_stop: !!options.error_report_stop,
|
|
593
|
+
project_key: options.project_key || "live",
|
|
594
|
+
product_line: options.product_line || "live",
|
|
595
|
+
onReport: options.onReport || function() {
|
|
596
|
+
}
|
|
597
|
+
// report 事件回调
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
function getDefaultLog() {
|
|
601
|
+
return {
|
|
602
|
+
// 开始播放(以player.play为基准)
|
|
603
|
+
start_play: {
|
|
604
|
+
start_play_time: 0,
|
|
605
|
+
// play 调用时间戳
|
|
606
|
+
event_key: "start_play"
|
|
607
|
+
},
|
|
608
|
+
// 首帧成功
|
|
609
|
+
first_frame: {
|
|
610
|
+
start: 0,
|
|
611
|
+
// 调用播放时间点
|
|
612
|
+
first_frame_view: 0,
|
|
613
|
+
event_key: "first_frame",
|
|
614
|
+
first_sei_delay: 0,
|
|
615
|
+
ntp_sync: 0,
|
|
616
|
+
ntp_delta: 0,
|
|
617
|
+
ttfb: -1,
|
|
618
|
+
// 从开始拉流到返回首字节
|
|
619
|
+
ttdb: -1,
|
|
620
|
+
// 从首字节到渲染出首帧
|
|
621
|
+
ttfb_end: 0
|
|
622
|
+
// 返回首字节unix时间戳
|
|
623
|
+
},
|
|
624
|
+
// 首帧失败
|
|
625
|
+
first_frame_failed: {
|
|
626
|
+
code: void 0,
|
|
627
|
+
msg: "",
|
|
628
|
+
event_key: "first_frame_failed"
|
|
629
|
+
},
|
|
630
|
+
// 卡顿开始
|
|
631
|
+
stall_start: {
|
|
632
|
+
ready_state: -1,
|
|
633
|
+
stall_start_time: 0,
|
|
634
|
+
event_key: "stall_start"
|
|
635
|
+
},
|
|
636
|
+
stalling: {
|
|
637
|
+
// 卡顿中
|
|
638
|
+
event_key: "stalling"
|
|
639
|
+
},
|
|
640
|
+
// 卡顿
|
|
641
|
+
stall: {
|
|
642
|
+
reason: 0,
|
|
643
|
+
// 0,网络卡顿; 1,解码卡顿
|
|
644
|
+
stall_start: 0,
|
|
645
|
+
// 卡顿开始时间戳
|
|
646
|
+
stall_end: 0,
|
|
647
|
+
// 卡顿结束时间戳
|
|
648
|
+
ready_state: 0,
|
|
649
|
+
event_key: "stall"
|
|
650
|
+
},
|
|
651
|
+
// 播放结束
|
|
652
|
+
play_stop: {
|
|
653
|
+
code: 0,
|
|
654
|
+
stop_time: 0,
|
|
655
|
+
// 关闭播放的时间戳, 用户离开页面
|
|
656
|
+
drop_percent: 0,
|
|
657
|
+
is_stream_received: 0,
|
|
658
|
+
// 1,拉到流;0,没有拉到流
|
|
659
|
+
stall_count: 0,
|
|
660
|
+
// 播放中卡顿次数
|
|
661
|
+
stall_time: 0,
|
|
662
|
+
// 播放中卡顿总时长
|
|
663
|
+
// play_time_on_no_frame: 0, //play_stop - start_play的时间
|
|
664
|
+
retry_count: 0,
|
|
665
|
+
// 播放过程中重试总次数
|
|
666
|
+
// first_frame_render_end: 0, //首帧渲染结束时间
|
|
667
|
+
duration: 0,
|
|
668
|
+
stall_count_per_100sec: 0,
|
|
669
|
+
stall_time_per_100sec: 0,
|
|
670
|
+
event_key: "play_stop",
|
|
671
|
+
dns_parse_time: -1,
|
|
672
|
+
redirect: -1,
|
|
673
|
+
ttfb: -1,
|
|
674
|
+
buffered: [],
|
|
675
|
+
is_firstframe_received: 0,
|
|
676
|
+
// 1, 拉到关键帧;0,没拉到关键帧
|
|
677
|
+
meta: null
|
|
678
|
+
},
|
|
679
|
+
// 播放过程中的心跳
|
|
680
|
+
playing: {
|
|
681
|
+
index: 0,
|
|
682
|
+
// playing 发出的第几条日志
|
|
683
|
+
stall_count: 0,
|
|
684
|
+
// 当前playing上报时间间隔卡顿总次数(如果卡顿跨分钟,则按照两次计算)
|
|
685
|
+
stall_time: 0,
|
|
686
|
+
// 当前playing上报时间间隔卡顿总时长
|
|
687
|
+
play_time: 1e4,
|
|
688
|
+
// 当前playing上报时间间隔 计算
|
|
689
|
+
retry_count: 0,
|
|
690
|
+
// 当前playing上报时间间隔重试总次数
|
|
691
|
+
is_last: 0,
|
|
692
|
+
// 调用了play_stop前的最后一个playing,is_last为1. 其他的playing事件时,is_last为0,一分钟上报一次
|
|
693
|
+
video_buffer_time: 0,
|
|
694
|
+
// 播放过程中视频缓冲时长(已经缓冲完成的)
|
|
695
|
+
audio_buffer_time: 0,
|
|
696
|
+
// 与视频相同
|
|
697
|
+
speed_switch_count: 0,
|
|
698
|
+
// 播放速度切换次数
|
|
699
|
+
speed_switch_info: "none",
|
|
700
|
+
// 播放速度切换具体信息
|
|
701
|
+
// sei_delay: 500, // 待处理 端到端延迟
|
|
702
|
+
download_speed: 0,
|
|
703
|
+
// 码率
|
|
704
|
+
// render_fps: this.render_fps, //帧率
|
|
705
|
+
decode_fps: 0,
|
|
706
|
+
render_fps: 0,
|
|
707
|
+
drop_count: 0,
|
|
708
|
+
// 丢帧数
|
|
709
|
+
drop_percent: 0,
|
|
710
|
+
// 丢帧率
|
|
711
|
+
sei_source: "",
|
|
712
|
+
sei_delay: 0,
|
|
713
|
+
ntp_sync: 0,
|
|
714
|
+
ntp_delta: 0,
|
|
715
|
+
// video_download_size: '', //下载大小 flv视频可获取
|
|
716
|
+
// video_play_size: '', // 播放大小 flv视频可获取
|
|
717
|
+
event_key: "playing",
|
|
718
|
+
// ios上部分统计不到play_stop。这里上报play_stop的参数, 以相同live_id最后一次playing统计stop相关数据
|
|
719
|
+
stop_time: 0,
|
|
720
|
+
// 关闭播放的时间戳, 用户离开页面
|
|
721
|
+
// is_stream_received: 1, // 1,拉到流;0,没有拉到流
|
|
722
|
+
duration: 0,
|
|
723
|
+
stall_count_per_100sec: 0,
|
|
724
|
+
stall_time_per_100sec: 0
|
|
725
|
+
// dns_parse_time: -1,
|
|
726
|
+
// redirect: -1,
|
|
727
|
+
// ttfb: -1,
|
|
728
|
+
// buffered: []
|
|
729
|
+
},
|
|
730
|
+
// 播放错误
|
|
731
|
+
play_error: {
|
|
732
|
+
code: void 0,
|
|
733
|
+
info: "",
|
|
734
|
+
event_key: "play_error"
|
|
735
|
+
},
|
|
736
|
+
// (软解) 解码效率低
|
|
737
|
+
play_low_decode: {
|
|
738
|
+
fps: -1,
|
|
739
|
+
decode_fps: -1,
|
|
740
|
+
bitrate: -1,
|
|
741
|
+
url: -1,
|
|
742
|
+
msg: "",
|
|
743
|
+
event_key: "play_low_decode"
|
|
744
|
+
},
|
|
745
|
+
// (软解)音画不同步,常见于丢帧
|
|
746
|
+
play_av_unsync: {
|
|
747
|
+
aDts: -1,
|
|
748
|
+
vDts: -1,
|
|
749
|
+
frameLength: -1,
|
|
750
|
+
currentTime: -1,
|
|
751
|
+
duration: 0,
|
|
752
|
+
event_key: "play_av_unsync"
|
|
753
|
+
},
|
|
754
|
+
// 拉流请求
|
|
755
|
+
play_loadstream: {
|
|
756
|
+
loadstream_url: "",
|
|
757
|
+
event_key: "play_loadstream"
|
|
758
|
+
},
|
|
759
|
+
// 拉到流
|
|
760
|
+
play_stream_loaded: {
|
|
761
|
+
event_key: "play_stream_loaded"
|
|
762
|
+
},
|
|
763
|
+
// 解析到音/视频的meta信息
|
|
764
|
+
play_metadata_loaded: {
|
|
765
|
+
metadata_type: "",
|
|
766
|
+
event_key: "play_metadata_loaded"
|
|
767
|
+
},
|
|
768
|
+
// 流异常,包括时间戳不连续等
|
|
769
|
+
stream_exception: {
|
|
770
|
+
event_key: "stream_exception"
|
|
771
|
+
},
|
|
772
|
+
// 暂停播放
|
|
773
|
+
pause: {
|
|
774
|
+
event_key: "pause"
|
|
775
|
+
},
|
|
776
|
+
// 切换播放链接url
|
|
777
|
+
play_url_change: {
|
|
778
|
+
event_key: "play_url_change"
|
|
779
|
+
},
|
|
780
|
+
// source open事件
|
|
781
|
+
source_opened: {
|
|
782
|
+
event_key: "source_opened"
|
|
783
|
+
},
|
|
784
|
+
// source updated end
|
|
785
|
+
source_updateend: {
|
|
786
|
+
event_key: "source_updateend"
|
|
787
|
+
},
|
|
788
|
+
// 是否起播
|
|
789
|
+
play_result: {
|
|
790
|
+
event_key: "play_result",
|
|
791
|
+
result: 0,
|
|
792
|
+
threshold: 15e3,
|
|
793
|
+
// ms
|
|
794
|
+
is_threshold: 0
|
|
795
|
+
},
|
|
796
|
+
// rts降级
|
|
797
|
+
degrade: {
|
|
798
|
+
event_key: "degrade",
|
|
799
|
+
payload: {}
|
|
800
|
+
},
|
|
801
|
+
// rts state change
|
|
802
|
+
rtcstatechange: {
|
|
803
|
+
event_key: "rtcstatechange"
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
function getCommonLog(options) {
|
|
808
|
+
var player = options.player;
|
|
809
|
+
var mediaType = player.config.mediaType;
|
|
810
|
+
return _objectSpread2({
|
|
811
|
+
project_key: options.project_key,
|
|
812
|
+
live_sdk_version: getPlayerCore(player) || player.hlsOps ? "2" : "-1",
|
|
813
|
+
player_sdk_version: player.version,
|
|
814
|
+
// eslint-disable-next-line no-undef
|
|
815
|
+
logger_version: "1.1.0-alpha.5",
|
|
816
|
+
// 由rollup 在编译时注入
|
|
817
|
+
report_version: "5",
|
|
818
|
+
product_line: options.product_line,
|
|
819
|
+
user_id: options.user_id,
|
|
820
|
+
device_id: options.device_id,
|
|
821
|
+
logger_id: getLogId(),
|
|
822
|
+
app_name: options.app_name,
|
|
823
|
+
cdn_ip: options.cdn_ip,
|
|
824
|
+
is_wasm: +(!!mediaType && mediaType !== "video"),
|
|
825
|
+
review_is_live: player.config.isLive ? 2 : 1,
|
|
826
|
+
aid: options.aid,
|
|
827
|
+
live_id: options.live_id || options.aid + "-" + options.user_id + "-" + Date.now(),
|
|
828
|
+
is_preview: options.is_preview ? 1 : 0,
|
|
829
|
+
codec_type: options.codec_type || "h264",
|
|
830
|
+
width: Math.floor(player.config.width),
|
|
831
|
+
height: Math.floor(player.config.height),
|
|
832
|
+
browser: sniffer.browser,
|
|
833
|
+
ua: navigator.userAgent,
|
|
834
|
+
href: window.location.href,
|
|
835
|
+
timestamp: 0,
|
|
836
|
+
fps: -1,
|
|
837
|
+
logger_init_time: Date.now(),
|
|
838
|
+
play_current_time: 0,
|
|
839
|
+
// 播放器播放时刻
|
|
840
|
+
cdn_play_url: player.config.url && player.config.url.startsWith("//") ? window.location.protocol + player.config.url : player.config.url,
|
|
841
|
+
play_format: getPlayFormat(player.config.url),
|
|
842
|
+
codec_support: -1
|
|
843
|
+
}, options.ext);
|
|
844
|
+
}
|
|
845
|
+
function Utf8ArrayToStr(array) {
|
|
846
|
+
var out, i2, len, c2;
|
|
847
|
+
var char2, char3;
|
|
848
|
+
out = "";
|
|
849
|
+
len = array.length;
|
|
850
|
+
i2 = 0;
|
|
851
|
+
while (i2 < len) {
|
|
852
|
+
c2 = array[i2++];
|
|
853
|
+
switch (c2 >> 4) {
|
|
854
|
+
case 0:
|
|
855
|
+
case 1:
|
|
856
|
+
case 2:
|
|
857
|
+
case 3:
|
|
858
|
+
case 4:
|
|
859
|
+
case 5:
|
|
860
|
+
case 6:
|
|
861
|
+
case 7:
|
|
862
|
+
out += String.fromCharCode(c2);
|
|
863
|
+
break;
|
|
864
|
+
case 12:
|
|
865
|
+
case 13:
|
|
866
|
+
char2 = array[i2++];
|
|
867
|
+
out += String.fromCharCode((c2 & 31) << 6 | char2 & 63);
|
|
868
|
+
break;
|
|
869
|
+
case 14:
|
|
870
|
+
char2 = array[i2++];
|
|
871
|
+
char3 = array[i2++];
|
|
872
|
+
out += String.fromCharCode((c2 & 15) << 12 | (char2 & 63) << 6 | (char3 & 63) << 0);
|
|
873
|
+
break;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
return out;
|
|
877
|
+
}
|
|
878
|
+
var getResourceTiming = function getResourceTiming2(url) {
|
|
879
|
+
var founds = performance.getEntriesByType("resource").filter(function(t2) {
|
|
880
|
+
return t2.name === url;
|
|
881
|
+
});
|
|
882
|
+
if (founds.length) {
|
|
883
|
+
var first = founds[0];
|
|
884
|
+
var last = founds[founds.length - 1];
|
|
885
|
+
return {
|
|
886
|
+
dns_parse_time: Number.parseInt(first.domainLookupEnd - first.domainLookupStart),
|
|
887
|
+
redirect: Number.parseInt(first.redirectEnd - first.redirectStart),
|
|
888
|
+
ttfb: Number.parseInt(last.responseStart - last.requestStart)
|
|
889
|
+
};
|
|
890
|
+
} else {
|
|
891
|
+
return {
|
|
892
|
+
dns_parse_time: -1,
|
|
893
|
+
redirect: -1,
|
|
894
|
+
ttfb: -1
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
};
|
|
898
|
+
var video_error = {
|
|
899
|
+
"1": "MEDIA_ERR_ABORTED",
|
|
900
|
+
"2": "MEDIA_ERR_NETWORK",
|
|
901
|
+
"3": "MEDIA_ERR_DECODE",
|
|
902
|
+
"4": "MEDIA_ERR_SRC_NOT_SUPPORTED"
|
|
903
|
+
};
|
|
904
|
+
var Manage = /* @__PURE__ */ function() {
|
|
905
|
+
_createClass(Manage2, [{
|
|
906
|
+
key: "videoSize",
|
|
907
|
+
get: function get() {
|
|
908
|
+
if (!this._player || !this._player.video) {
|
|
909
|
+
return {
|
|
910
|
+
width: 0,
|
|
911
|
+
height: 0
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
return {
|
|
915
|
+
width: this._player.video.videoWidth,
|
|
916
|
+
height: this._player.video.videoHeight
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
}]);
|
|
920
|
+
function Manage2(logOptions) {
|
|
921
|
+
var Tea = logOptions.Tea;
|
|
922
|
+
if (!Tea) {
|
|
923
|
+
throw new Error("lack Tea option");
|
|
924
|
+
}
|
|
925
|
+
if (Tea.event) {
|
|
926
|
+
this.Tea = Tea.event.bind(Tea);
|
|
927
|
+
} else {
|
|
928
|
+
this.Tea = Tea;
|
|
929
|
+
}
|
|
930
|
+
this.logOptions = logOptions;
|
|
931
|
+
this._player = logOptions.player;
|
|
932
|
+
}
|
|
933
|
+
var _proto = Manage2.prototype;
|
|
934
|
+
_proto.push = function push(log) {
|
|
935
|
+
var url = this._player.config.url;
|
|
936
|
+
if (this._player.video) {
|
|
937
|
+
log.play_current_time = this._player.currentTime;
|
|
938
|
+
}
|
|
939
|
+
log.cdn_play_url = url && url.startsWith("//") ? window.location.protocol + url : url;
|
|
940
|
+
log.live_stream_session_id = getUrlQuery(url, "session_id");
|
|
941
|
+
log.play_format = getPlayFormat(url);
|
|
942
|
+
log.timestamp = getCurrentTime();
|
|
943
|
+
var _getDeviceInfo = getDeviceInfo(), cpu_core_number = _getDeviceInfo.cpu_core_number, memory_usage = _getDeviceInfo.memory_usage, network_downlink = _getDeviceInfo.network_downlink;
|
|
944
|
+
log.cpu_core_number = cpu_core_number;
|
|
945
|
+
log.memory_usage = memory_usage;
|
|
946
|
+
log.network_downlink = network_downlink;
|
|
947
|
+
Object.assign(log, _objectSpread2({}, this.videoSize));
|
|
948
|
+
this.send(log);
|
|
949
|
+
};
|
|
950
|
+
_proto.send = function send(log) {
|
|
951
|
+
if (log.event_key) {
|
|
952
|
+
if (this.logOptions.onReport) {
|
|
953
|
+
this.logOptions.onReport(log.event_key, log);
|
|
954
|
+
}
|
|
955
|
+
this.Tea(log.event_key, _objectSpread2({}, log));
|
|
956
|
+
}
|
|
957
|
+
};
|
|
958
|
+
return Manage2;
|
|
959
|
+
}();
|
|
960
|
+
var navgatorOnlineSupported = function navgatorOnlineSupported2() {
|
|
961
|
+
return typeof navigator.onLine !== "undefined";
|
|
962
|
+
};
|
|
963
|
+
var navigatorConnectionType = function navigatorConnectionType2() {
|
|
964
|
+
var _navigator = navigator, connection = _navigator.connection;
|
|
965
|
+
return connection && (connection.effectiveType || connection.type);
|
|
966
|
+
};
|
|
967
|
+
var getNetStat = function getNetStat2() {
|
|
968
|
+
if (navgatorOnlineSupported()) {
|
|
969
|
+
if (navigator.onLine) {
|
|
970
|
+
return navigatorConnectionType() || sniffer.device;
|
|
971
|
+
} else {
|
|
972
|
+
return "none";
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
return "unknown";
|
|
976
|
+
};
|
|
977
|
+
var videoEvts = ["play", "playing", "pause", "ended", "error", "seeking", "seeked", "timeupdate", "waiting", "canplay", "canplaythrough", "durationchange", "ratechange", "volumechange", "loadeddata"];
|
|
978
|
+
var LoggerControl = /* @__PURE__ */ function() {
|
|
979
|
+
function LoggerControl2(options) {
|
|
980
|
+
this.options = options;
|
|
981
|
+
this.logger = new XgLiveLogger(options);
|
|
982
|
+
this.restart = this.restart.bind(this);
|
|
983
|
+
this.bindUrlChange();
|
|
984
|
+
sniffer.browser.includes("Chrome");
|
|
985
|
+
}
|
|
986
|
+
var _proto = LoggerControl2.prototype;
|
|
987
|
+
_proto.restart = function restart(report_stop) {
|
|
988
|
+
this.destroy(typeof report_stop === "string" ? false : Boolean(report_stop));
|
|
989
|
+
this.logger = new XgLiveLogger(this.options);
|
|
990
|
+
this.bindUrlChange();
|
|
991
|
+
this.logger.reportStartPlay();
|
|
992
|
+
this.logger.handlePlayerComlete();
|
|
993
|
+
};
|
|
994
|
+
_proto.bindUrlChange = function bindUrlChange() {
|
|
995
|
+
if (this.options && this.options.player && !this.options.manual_restart) {
|
|
996
|
+
this.options.player.on("urlchange", this.restart);
|
|
997
|
+
}
|
|
998
|
+
};
|
|
999
|
+
_proto.setNTP = function setNTP(ntp) {
|
|
1000
|
+
this.logger.setNTP(ntp);
|
|
1001
|
+
};
|
|
1002
|
+
_proto.updateExt = function updateExt(ext) {
|
|
1003
|
+
this.options.ext = Object.assign(this.options.ext || {}, ext);
|
|
1004
|
+
if (this.logger) {
|
|
1005
|
+
this.logger.updateExt(ext);
|
|
1006
|
+
}
|
|
1007
|
+
};
|
|
1008
|
+
_proto.destroy = function destroy(report_stop) {
|
|
1009
|
+
this.logger.destroy(report_stop);
|
|
1010
|
+
this.logger = null;
|
|
1011
|
+
if (this.options && this.options.player && !this.options.manual_restart) {
|
|
1012
|
+
this.options.player.off("urlchange", this.restart);
|
|
1013
|
+
}
|
|
1014
|
+
};
|
|
1015
|
+
return LoggerControl2;
|
|
1016
|
+
}();
|
|
1017
|
+
var XgLiveLogger = /* @__PURE__ */ function() {
|
|
1018
|
+
_createClass(XgLiveLogger2, [{
|
|
1019
|
+
key: "videoSize",
|
|
1020
|
+
get: function get() {
|
|
1021
|
+
if (!this.player) {
|
|
1022
|
+
return {
|
|
1023
|
+
width: 0,
|
|
1024
|
+
height: 0
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
return {
|
|
1028
|
+
width: this.player.video.videoWidth,
|
|
1029
|
+
height: this.player.video.videoHeight
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
}, {
|
|
1033
|
+
key: "player",
|
|
1034
|
+
get: function get() {
|
|
1035
|
+
return this._player;
|
|
1036
|
+
}
|
|
1037
|
+
}, {
|
|
1038
|
+
key: "logmanager",
|
|
1039
|
+
get: function get() {
|
|
1040
|
+
return this._logmanager;
|
|
1041
|
+
}
|
|
1042
|
+
}, {
|
|
1043
|
+
key: "ntpTime",
|
|
1044
|
+
get: function get() {
|
|
1045
|
+
return Date.now() - this.ntpDelta;
|
|
1046
|
+
}
|
|
1047
|
+
}]);
|
|
1048
|
+
function XgLiveLogger2(options) {
|
|
1049
|
+
if (!options.player) {
|
|
1050
|
+
throw new Error("option player is necessary");
|
|
1051
|
+
}
|
|
1052
|
+
this.options = Object.assign({}, options, getDefaultOptions(options));
|
|
1053
|
+
this._player = this.options.player;
|
|
1054
|
+
this._url = this._player.config.url;
|
|
1055
|
+
this.project_key = options.project_key || "live";
|
|
1056
|
+
this.product_line = options.product_line || "live";
|
|
1057
|
+
this.ntpDelta = this.options.ntp ? Date.now() - this.options.ntp : 0;
|
|
1058
|
+
this.inWaitingStart = 0;
|
|
1059
|
+
this.errorNumber = 0;
|
|
1060
|
+
this.tempDroppedFrameCount = 0;
|
|
1061
|
+
this.tempTotalFrameCount = 0;
|
|
1062
|
+
this._logmanager = new Manage(this.options);
|
|
1063
|
+
this.init();
|
|
1064
|
+
this.started = false;
|
|
1065
|
+
this.destroyed = false;
|
|
1066
|
+
this.completed = false;
|
|
1067
|
+
this.firstFrameViewed = false;
|
|
1068
|
+
this.cacheRtcStats = {};
|
|
1069
|
+
}
|
|
1070
|
+
var _proto2 = XgLiveLogger2.prototype;
|
|
1071
|
+
_proto2.setNTP = function setNTP(ntp) {
|
|
1072
|
+
if (this.options) {
|
|
1073
|
+
this.options.ntp = ntp;
|
|
1074
|
+
this.ntpDelta = Date.now() - this.options.ntp;
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
_proto2.init = function init() {
|
|
1078
|
+
this.bindCtx();
|
|
1079
|
+
this.initLog();
|
|
1080
|
+
this.initEvt();
|
|
1081
|
+
};
|
|
1082
|
+
_proto2.bindCtx = function bindCtx() {
|
|
1083
|
+
this.handlePlayerComlete = this.handlePlayerComlete.bind(this);
|
|
1084
|
+
this.handlePlayerPlaying = this.handlePlayerPlaying.bind(this);
|
|
1085
|
+
this.destroyFunc = this.destroyFunc.bind(this);
|
|
1086
|
+
this.handleUserLeave = this.handleUserLeave.bind(this);
|
|
1087
|
+
this.handlePlayerError = this.handlePlayerError.bind(this);
|
|
1088
|
+
this.handlePlayerReady = this.handlePlayerReady.bind(this);
|
|
1089
|
+
this.handlePlayerWaiting = this.handlePlayerWaiting.bind(this);
|
|
1090
|
+
this.handleAVUnsync = this.handleAVUnsync.bind(this);
|
|
1091
|
+
this.handlePlayerPause = this.handlePlayerPause.bind(this);
|
|
1092
|
+
this.handleTTFB = this.handleTTFB.bind(this);
|
|
1093
|
+
this.handleUrlChange = this.handleUrlChange.bind(this);
|
|
1094
|
+
this.handleKeyframe = this.handleKeyframe.bind(this);
|
|
1095
|
+
this.handleSourceOpen = this.handleSourceOpen.bind(this);
|
|
1096
|
+
this.handleBufferAppend = this.handleBufferAppend.bind(this);
|
|
1097
|
+
this.handleCoreEvent = this.handleCoreEvent.bind(this);
|
|
1098
|
+
this.handleDegrade = this.handleDegrade.bind(this);
|
|
1099
|
+
};
|
|
1100
|
+
_proto2.initLog = function initLog() {
|
|
1101
|
+
var _this = this;
|
|
1102
|
+
var options = this.options;
|
|
1103
|
+
var player = options.player;
|
|
1104
|
+
var isHLS = player.hlsOps !== void 0;
|
|
1105
|
+
this.commonParams = _objectSpread2({
|
|
1106
|
+
os: sniffer.operation_os
|
|
1107
|
+
}, getCommonLog(options));
|
|
1108
|
+
this.log = Object.assign({}, getDefaultLog());
|
|
1109
|
+
var self2 = this;
|
|
1110
|
+
for (var logKey in this.log) {
|
|
1111
|
+
var _loop = function _loop2(commonKey2) {
|
|
1112
|
+
Object.defineProperty(_this.log[logKey], commonKey2, {
|
|
1113
|
+
get: function get() {
|
|
1114
|
+
if (this["_" + commonKey2] == void 0)
|
|
1115
|
+
return self2.commonParams[commonKey2];
|
|
1116
|
+
return this["_" + commonKey2];
|
|
1117
|
+
},
|
|
1118
|
+
set: function set(val) {
|
|
1119
|
+
this["_" + commonKey2] = val;
|
|
1120
|
+
},
|
|
1121
|
+
enumerable: true
|
|
1122
|
+
});
|
|
1123
|
+
};
|
|
1124
|
+
for (var commonKey in this.commonParams) {
|
|
1125
|
+
_loop(commonKey);
|
|
1126
|
+
}
|
|
1127
|
+
if (isHLS) {
|
|
1128
|
+
Object.defineProperty(this.log[logKey], "m3u8", {
|
|
1129
|
+
get: function get() {
|
|
1130
|
+
if (player.__core__) {
|
|
1131
|
+
var m3u8Text = player.__core__.m3u8Text;
|
|
1132
|
+
if (m3u8Text) {
|
|
1133
|
+
return m3u8Text.slice(0, 500 * 500);
|
|
1134
|
+
}
|
|
1135
|
+
return "";
|
|
1136
|
+
}
|
|
1137
|
+
return "";
|
|
1138
|
+
},
|
|
1139
|
+
enumerable: true
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
Object.defineProperty(this.log[logKey], "volume", {
|
|
1143
|
+
get: function get() {
|
|
1144
|
+
if (!player || !player.video)
|
|
1145
|
+
return;
|
|
1146
|
+
return player.volume || 0;
|
|
1147
|
+
},
|
|
1148
|
+
enumerable: true
|
|
1149
|
+
});
|
|
1150
|
+
Object.defineProperty(this.log[logKey], "access", {
|
|
1151
|
+
get: function get() {
|
|
1152
|
+
return getNetStat();
|
|
1153
|
+
},
|
|
1154
|
+
enumerable: true
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
};
|
|
1158
|
+
_proto2.updateExt = function updateExt(ext) {
|
|
1159
|
+
for (var logKey in this.log) {
|
|
1160
|
+
for (var extKey in ext) {
|
|
1161
|
+
this.log[logKey][extKey] = ext[extKey];
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
};
|
|
1165
|
+
_proto2.reportStartPlay = function reportStartPlay() {
|
|
1166
|
+
if (!this.started) {
|
|
1167
|
+
this.started = true;
|
|
1168
|
+
this.log.start_play.start_play_time = this.log.start_play.timestamp = getCurrentTime();
|
|
1169
|
+
this.logmanager.push(this.log.start_play, true);
|
|
1170
|
+
}
|
|
1171
|
+
};
|
|
1172
|
+
_proto2.initWindowListener = function initWindowListener() {
|
|
1173
|
+
if (sniffer.device === "pc") {
|
|
1174
|
+
window.addEventListener("beforeunload", this.handleUserLeave);
|
|
1175
|
+
} else if (sniffer.device === "mobile") {
|
|
1176
|
+
window.addEventListener("beforeunload", this.handleUserLeave);
|
|
1177
|
+
window.addEventListener("pagehide", this.handleUserLeave);
|
|
1178
|
+
}
|
|
1179
|
+
};
|
|
1180
|
+
_proto2.removeWindowListener = function removeWindowListener() {
|
|
1181
|
+
if (sniffer.device === "pc") {
|
|
1182
|
+
window.removeEventListener("beforeunload", this.handleUserLeave);
|
|
1183
|
+
} else if (sniffer.device === "mobile") {
|
|
1184
|
+
window.removeEventListener("beforeunload", this.handleUserLeave);
|
|
1185
|
+
window.removeEventListener("pagehide", this.handleUserLeave);
|
|
1186
|
+
}
|
|
1187
|
+
};
|
|
1188
|
+
_proto2.initEvt = function initEvt() {
|
|
1189
|
+
var _this2 = this;
|
|
1190
|
+
var player = this.player;
|
|
1191
|
+
videoEvts.forEach(function(name) {
|
|
1192
|
+
_this2["handleVideo" + name + "Evt"] = function() {
|
|
1193
|
+
_this2["handleVideo" + name] && _this2["handleVideo" + name]();
|
|
1194
|
+
};
|
|
1195
|
+
_this2.initWindowListener();
|
|
1196
|
+
_this2.bindVideoEvt(name, _this2["handleVideo" + name + "Evt"]);
|
|
1197
|
+
});
|
|
1198
|
+
player.once("error", this.handlePlayerError);
|
|
1199
|
+
player.once("complete", this.handlePlayerComlete);
|
|
1200
|
+
player.once("playing", this.handlePlayerPlaying);
|
|
1201
|
+
player.once("timeupdate", this.handlePlayerPlaying);
|
|
1202
|
+
player.once("destroy", this.destroyFunc);
|
|
1203
|
+
player.on("ready", this.handlePlayerReady);
|
|
1204
|
+
player.on("waiting", this.handlePlayerWaiting);
|
|
1205
|
+
player.on("pause", this.handlePlayerPause);
|
|
1206
|
+
player.on("urlchange", this.handleUrlChange);
|
|
1207
|
+
player.once("sourceopen", this.handleSourceOpen);
|
|
1208
|
+
player.once("bufferappend", this.handleBufferAppend);
|
|
1209
|
+
player.on("core_event", this.handleCoreEvent);
|
|
1210
|
+
player.on("degrade", this.handleDegrade);
|
|
1211
|
+
this.hiJackPlayerStart();
|
|
1212
|
+
};
|
|
1213
|
+
_proto2.handleCoreEvent = function handleCoreEvent(info) {
|
|
1214
|
+
var eventName = info.eventName, headers = info.headers, pts = info.pts, type = info.type, meta = info.meta, sei = info.sei, decodeFps = info.decodeFps, url = info.url, state = info.state;
|
|
1215
|
+
switch (eventName) {
|
|
1216
|
+
case "core.ttfb":
|
|
1217
|
+
this.handleTTFB(info);
|
|
1218
|
+
break;
|
|
1219
|
+
case "core.loadresponseheaders":
|
|
1220
|
+
var serverIp = headers.get("X-Server-Ip");
|
|
1221
|
+
if (this.player.hlsOps !== void 0) {
|
|
1222
|
+
this.log.play_stop.review_ts_count += 1;
|
|
1223
|
+
}
|
|
1224
|
+
if (serverIp) {
|
|
1225
|
+
this.commonParams.cdn_ip = serverIp;
|
|
1226
|
+
}
|
|
1227
|
+
break;
|
|
1228
|
+
case "core.loadretry":
|
|
1229
|
+
this.log.play_stop.retry_count++;
|
|
1230
|
+
break;
|
|
1231
|
+
case "core.keyframe":
|
|
1232
|
+
this.handleKeyframe(pts);
|
|
1233
|
+
break;
|
|
1234
|
+
case "core.metadataparsed":
|
|
1235
|
+
this.handleMetaDataLoaded(type, meta);
|
|
1236
|
+
break;
|
|
1237
|
+
case "core.sei":
|
|
1238
|
+
this.handleSEIParsed(sei);
|
|
1239
|
+
break;
|
|
1240
|
+
case "core.lowdecode":
|
|
1241
|
+
if (this.commonParams.is_wasm) {
|
|
1242
|
+
Object.assign(this.log.play_low_decode, info || {});
|
|
1243
|
+
this.log.play_low_decode.decode_fps = decodeFps;
|
|
1244
|
+
this.log.play_low_decode.timestamp = getCurrentTime();
|
|
1245
|
+
this.logmanager.push(this.log.play_low_decode, true);
|
|
1246
|
+
this.commonParams.is_wasm = 0;
|
|
1247
|
+
}
|
|
1248
|
+
break;
|
|
1249
|
+
case "core.largeavgap":
|
|
1250
|
+
this.handleAVUnsync(info);
|
|
1251
|
+
break;
|
|
1252
|
+
case "core.loadstart":
|
|
1253
|
+
this.handlePlayerLoadStream(info);
|
|
1254
|
+
this.reportStartPlay();
|
|
1255
|
+
break;
|
|
1256
|
+
case "core.loadcomplete":
|
|
1257
|
+
this.handlePlayerLoadedStream(info);
|
|
1258
|
+
break;
|
|
1259
|
+
case "core.streamexception":
|
|
1260
|
+
this.handleStreamException(info);
|
|
1261
|
+
break;
|
|
1262
|
+
case "core.rtcstatechange":
|
|
1263
|
+
this.logmanager.push(Object.assign({
|
|
1264
|
+
url,
|
|
1265
|
+
state
|
|
1266
|
+
}, this.log.rtcstatechange));
|
|
1267
|
+
break;
|
|
1268
|
+
}
|
|
1269
|
+
};
|
|
1270
|
+
_proto2.handleDegrade = function handleDegrade(payload) {
|
|
1271
|
+
this.log.degrade.payload = payload;
|
|
1272
|
+
this.logmanager.push(this.log.degrade, true);
|
|
1273
|
+
};
|
|
1274
|
+
_proto2.hiJackPlayerStart = function hiJackPlayerStart() {
|
|
1275
|
+
var _arguments = arguments, _this3 = this;
|
|
1276
|
+
this.player._start = this.player.start;
|
|
1277
|
+
var player = this.player;
|
|
1278
|
+
player.start = function() {
|
|
1279
|
+
try {
|
|
1280
|
+
if (player._start) {
|
|
1281
|
+
return player._start.apply(player, Array.prototype.slice.call(_arguments, 0));
|
|
1282
|
+
}
|
|
1283
|
+
} catch (e3) {
|
|
1284
|
+
}
|
|
1285
|
+
if (!_this3.destroyed) {
|
|
1286
|
+
_this3.handlePlayerComlete();
|
|
1287
|
+
}
|
|
1288
|
+
};
|
|
1289
|
+
};
|
|
1290
|
+
_proto2.handleTTFB = function handleTTFB(params) {
|
|
1291
|
+
var _ref = params || {}, end = _ref.end, elapsed = _ref.elapsed;
|
|
1292
|
+
this.log.first_frame.ttfb = elapsed || -1;
|
|
1293
|
+
this.log.first_frame.ttfb_end = end || 0;
|
|
1294
|
+
};
|
|
1295
|
+
_proto2.handleUrlChange = function handleUrlChange(url) {
|
|
1296
|
+
this.logmanager.push(Object.assign(this.log.play_url_change, {
|
|
1297
|
+
url,
|
|
1298
|
+
timestamp: getCurrentTime()
|
|
1299
|
+
}));
|
|
1300
|
+
};
|
|
1301
|
+
_proto2.handleKeyframe = function handleKeyframe(pts) {
|
|
1302
|
+
this.log.play_stop.is_firstframe_received = 1;
|
|
1303
|
+
this.log.play_stop.firstframe_pts = pts;
|
|
1304
|
+
};
|
|
1305
|
+
_proto2.handleSourceOpen = function handleSourceOpen() {
|
|
1306
|
+
this.log.source_opened.timestamp = getCurrentTime();
|
|
1307
|
+
this.logmanager.push(this.log.source_opened);
|
|
1308
|
+
};
|
|
1309
|
+
_proto2.handleBufferAppend = function handleBufferAppend() {
|
|
1310
|
+
this.log.source_updateend.timestamp = getCurrentTime();
|
|
1311
|
+
this.logmanager.push(this.log.source_updateend);
|
|
1312
|
+
};
|
|
1313
|
+
_proto2.handlePlayerPause = function handlePlayerPause() {
|
|
1314
|
+
this.log.pause.timestamp = getCurrentTime();
|
|
1315
|
+
this.logmanager.push(this.log.pause, true);
|
|
1316
|
+
this.stallEnd();
|
|
1317
|
+
};
|
|
1318
|
+
_proto2.handlePlayerError = function handlePlayerError(err) {
|
|
1319
|
+
this.errorNumber = 1;
|
|
1320
|
+
var errorType = err.errorType;
|
|
1321
|
+
var code = err.errorCode;
|
|
1322
|
+
Object.assign(this.log.play_error, _objectSpread2({
|
|
1323
|
+
timestamp: getCurrentTime(),
|
|
1324
|
+
code: err.httpCode || code || (errorType === "parse" ? 31 : 21),
|
|
1325
|
+
info: err.message,
|
|
1326
|
+
detail: JSON.stringify(err)
|
|
1327
|
+
}, this.videoSize));
|
|
1328
|
+
this.logmanager.push(this.log.play_error, true);
|
|
1329
|
+
if (this.destroyed) {
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
if (this.log.first_frame.first_frame_view === 0) {
|
|
1333
|
+
Object.assign(this.log.first_frame_failed, {
|
|
1334
|
+
code: code || (errorType === "parse" ? 31 : 21),
|
|
1335
|
+
msg: err.message
|
|
1336
|
+
});
|
|
1337
|
+
if (this.log.first_frame_failed.timestamp !== void 0) {
|
|
1338
|
+
this.log.first_frame_failed.timestamp = getCurrentTime();
|
|
1339
|
+
}
|
|
1340
|
+
this.logmanager.push(this.log.first_frame_failed, true);
|
|
1341
|
+
if (!this.log.play_result.is_threshold) {
|
|
1342
|
+
this.clearPlayResultTimer();
|
|
1343
|
+
this.log.play_result.reason = err.message || "first frame failed";
|
|
1344
|
+
this.log.play_result.code = this.log.play_error.code;
|
|
1345
|
+
this.logmanager.push(this.log.play_result, true);
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
if (this.options.error_report_stop) {
|
|
1349
|
+
this.handleUserLeave();
|
|
1350
|
+
} else {
|
|
1351
|
+
this.updatePlayStopParams();
|
|
1352
|
+
}
|
|
1353
|
+
};
|
|
1354
|
+
_proto2.handlePlayerLoadStream = function handlePlayerLoadStream(info) {
|
|
1355
|
+
var url = info.url, offersdp = info.offersdp, sessionId = info.sessionId;
|
|
1356
|
+
if (typeof url !== "string") {
|
|
1357
|
+
return;
|
|
1358
|
+
}
|
|
1359
|
+
var play_loadstream = this.log.play_loadstream;
|
|
1360
|
+
play_loadstream.timestamp = getCurrentTime();
|
|
1361
|
+
play_loadstream.loadstream_url = url;
|
|
1362
|
+
play_loadstream.offersdp = offersdp;
|
|
1363
|
+
play_loadstream.sessionId = sessionId;
|
|
1364
|
+
this.logmanager.push(play_loadstream);
|
|
1365
|
+
};
|
|
1366
|
+
_proto2.handlePlayerLoadedStream = function handlePlayerLoadedStream(info) {
|
|
1367
|
+
var play_stream_loaded = this.log.play_stream_loaded;
|
|
1368
|
+
play_stream_loaded.timestamp = getCurrentTime();
|
|
1369
|
+
Object.assign(play_stream_loaded, info);
|
|
1370
|
+
this.logmanager.push(play_stream_loaded);
|
|
1371
|
+
};
|
|
1372
|
+
_proto2.handleSEIParsed = function handleSEIParsed(sei) {
|
|
1373
|
+
var _this$log = this.log, playing = _this$log.playing, first_frame = _this$log.first_frame;
|
|
1374
|
+
if (sei.code === 100) {
|
|
1375
|
+
var seiString = Utf8ArrayToStr(sei.content);
|
|
1376
|
+
seiString = seiString.slice(seiString.indexOf("{"), seiString.lastIndexOf("}") + 1);
|
|
1377
|
+
try {
|
|
1378
|
+
var seiContent = JSON.parse(seiString);
|
|
1379
|
+
var seiDelay = this.getPlayerBuffer() + this.ntpTime - seiContent.ts;
|
|
1380
|
+
playing.sei_delay = seiDelay;
|
|
1381
|
+
playing.sei_source = seiContent.source;
|
|
1382
|
+
playing.ntp_sync = this.options.ntp ? 1 : 0;
|
|
1383
|
+
playing.ntp_delta = this.ntp_delta;
|
|
1384
|
+
first_frame.first_sei_delay = seiDelay;
|
|
1385
|
+
first_frame.ntp_sync = this.options.ntp ? 1 : 0;
|
|
1386
|
+
first_frame.ntp_delta = this.ntp_delta;
|
|
1387
|
+
} catch (e3) {
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
};
|
|
1391
|
+
_proto2.handleMetaDataLoaded = function handleMetaDataLoaded(type, meta) {
|
|
1392
|
+
this.log.play_stop.meta = this.log.play_stop.meta || {};
|
|
1393
|
+
if (type) {
|
|
1394
|
+
this.log.play_stop.meta[type] = meta;
|
|
1395
|
+
}
|
|
1396
|
+
this.log.play_metadata_loaded.timestamp = getCurrentTime();
|
|
1397
|
+
this.log.play_metadata_loaded.metadata_type = type;
|
|
1398
|
+
if (meta) {
|
|
1399
|
+
this.log.play_metadata_loaded.meta = meta;
|
|
1400
|
+
this.log.play_metadata_loaded.codec = meta.codec;
|
|
1401
|
+
if (type === "video") {
|
|
1402
|
+
this.commonParams.codec_type = meta.codec;
|
|
1403
|
+
this.commonParams.codec_support = isCodecSupport(meta.codec);
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
if (!meta) {
|
|
1407
|
+
this.log.play_metadata_loaded.meta = void 0;
|
|
1408
|
+
this.log.play_metadata_loaded.codec = void 0;
|
|
1409
|
+
if (type === "video") {
|
|
1410
|
+
this.commonParams.codec_type = "unknown";
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
this.logmanager.push(this.log.play_metadata_loaded);
|
|
1414
|
+
};
|
|
1415
|
+
_proto2.handleAVUnsync = function handleAVUnsync(unsyncInfo) {
|
|
1416
|
+
Object.assign(this.log.play_av_unsync, unsyncInfo || {});
|
|
1417
|
+
this.log.play_av_unsync.timestamp = getCurrentTime();
|
|
1418
|
+
this.logmanager.push(this.log.play_av_unsync, false);
|
|
1419
|
+
};
|
|
1420
|
+
_proto2.handleStreamException = function handleStreamException(info) {
|
|
1421
|
+
this.logmanager.push(Object.assign({}, this.log.stream_exception, info));
|
|
1422
|
+
};
|
|
1423
|
+
_proto2.handlePlayerComlete = function handlePlayerComlete() {
|
|
1424
|
+
if (this.completed) {
|
|
1425
|
+
return;
|
|
1426
|
+
}
|
|
1427
|
+
this.completed = true;
|
|
1428
|
+
this.core = getPlayerCore(this.player);
|
|
1429
|
+
if (this.core) {
|
|
1430
|
+
this.commonParams.live_sdk_version = "2";
|
|
1431
|
+
}
|
|
1432
|
+
if (this.player.config.autoplay || this.player.config.videoInit) {
|
|
1433
|
+
this.reportStartPlay();
|
|
1434
|
+
}
|
|
1435
|
+
};
|
|
1436
|
+
_proto2.getPlayerBuffer = function getPlayerBuffer() {
|
|
1437
|
+
var buffered = this.player.video.buffered;
|
|
1438
|
+
if (buffered) {
|
|
1439
|
+
var bufferIdx = Math.max(0, buffered.length - 1);
|
|
1440
|
+
try {
|
|
1441
|
+
var bufferedTime = Number.parseInt((buffered.end(bufferIdx) - this.player.video.currentTime) * 1e3);
|
|
1442
|
+
this.log.playing.audio_buffer_time = this.log.playing.video_buffer_time = bufferedTime;
|
|
1443
|
+
return bufferedTime;
|
|
1444
|
+
} catch (e3) {
|
|
1445
|
+
return 0;
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
};
|
|
1449
|
+
_proto2.getPlayerDownloadSpeed = function getPlayerDownloadSpeed() {
|
|
1450
|
+
if (this.core && this.core.core) {
|
|
1451
|
+
if (typeof this.core.core.speedInfo === "function") {
|
|
1452
|
+
return this.core.core.speedInfo().speed;
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
_proto2.getPlayerQuality = function getPlayerQuality() {
|
|
1457
|
+
var video = this.player.video;
|
|
1458
|
+
if (video.getVideoPlaybackQuality) {
|
|
1459
|
+
var quality = video.getVideoPlaybackQuality();
|
|
1460
|
+
this.log.playing.drop_count = quality.droppedVideoFrames - this.tempDroppedFrameCount;
|
|
1461
|
+
this.log.playing.drop_percent = Number.parseFloat(this.tempTotalFrameCount / quality.totalVideoFrames).toFixed(1);
|
|
1462
|
+
this.log.play_stop.drop_percent = Number.parseFloat(quality.droppedVideoFrames / quality.totalVideoFrames).toFixed(1);
|
|
1463
|
+
this.tempDroppedFrameCount = quality.droppedVideoFrames;
|
|
1464
|
+
this.tempTotalFrameCount = quality.totalVideoFrames;
|
|
1465
|
+
}
|
|
1466
|
+
};
|
|
1467
|
+
_proto2.getRtcStats = function getRtcStats(duration, first) {
|
|
1468
|
+
try {
|
|
1469
|
+
var _this5 = this;
|
|
1470
|
+
var rtm = _this5.player.plugins.rts || _this5.player.plugins.rtm;
|
|
1471
|
+
var pc = rtm && rtm.pc;
|
|
1472
|
+
var rtc_stats = {};
|
|
1473
|
+
if (!pc)
|
|
1474
|
+
return Promise.resolve(rtc_stats);
|
|
1475
|
+
return Promise.resolve(pc.getStats()).then(function(tmp) {
|
|
1476
|
+
tmp.forEach(function(stat) {
|
|
1477
|
+
var type = stat.type, mediaType = stat.mediaType, bytesReceived = stat.bytesReceived, packetsReceived = stat.packetsReceived, audioLevel = stat.audioLevel, concealmentEvents = stat.concealmentEvents, remoteTimestamp = stat.remoteTimestamp, timestamp = stat.timestamp, framesDropped = stat.framesDropped, keyFramesDecoded = stat.keyFramesDecoded, totalDecodeTime = stat.totalDecodeTime, framesDecoded = stat.framesDecoded, frameHeight = stat.frameHeight, frameWidth = stat.frameWidth, framesReceived = stat.framesReceived, jitterBufferDelay = stat.jitterBufferDelay, jitterBufferEmittedCount = stat.jitterBufferEmittedCount, jitter = stat.jitter, nackCount = stat.nackCount, packetsLost = stat.packetsLost, pliCount = stat.pliCount, totalSamplesReceived = stat.totalSamplesReceived, concealedSamples = stat.concealedSamples, currentRoundTripTime = stat.currentRoundTripTime, decoderImplementation = stat.decoderImplementation, mimeType = stat.mimeType, freezeCount = stat.freezeCount, totalFreezesDuration = stat.totalFreezesDuration, totalPausesDuration = stat.totalPausesDuration;
|
|
1478
|
+
switch (type) {
|
|
1479
|
+
case "inbound-rtp":
|
|
1480
|
+
if (mediaType === "audio") {
|
|
1481
|
+
rtc_stats.audio_bytes_received = bytesReceived - (_this5.cacheRtcStats.audioBytesReceived || 0);
|
|
1482
|
+
_this5.cacheRtcStats.audioBytesReceived = bytesReceived;
|
|
1483
|
+
rtc_stats.audio_packets_lost = packetsLost - (_this5.cacheRtcStats.audioPacketsLost || 0);
|
|
1484
|
+
rtc_stats.audio_packets_received = packetsReceived - (_this5.cacheRtcStats.audioPacketsReceived || 0);
|
|
1485
|
+
_this5.cacheRtcStats.audioPacketsLost = packetsLost;
|
|
1486
|
+
_this5.cacheRtcStats.audioPacketsReceived = packetsReceived;
|
|
1487
|
+
rtc_stats.audio_level = audioLevel;
|
|
1488
|
+
rtc_stats.concealment_event = concealmentEvents;
|
|
1489
|
+
rtc_stats.audio_fraction_lost = rtc_stats.audio_packets_lost / rtc_stats.audio_packets_received;
|
|
1490
|
+
if (_this5.cacheRtcStats.totalSamplesReceived !== void 0) {
|
|
1491
|
+
rtc_stats.audio_rec_sample_rate = (totalSamplesReceived - _this5.cacheRtcStats.totalSamplesReceived) / duration;
|
|
1492
|
+
}
|
|
1493
|
+
_this5.cacheRtcStats.totalSamplesReceived = totalSamplesReceived;
|
|
1494
|
+
rtc_stats.concealed_samples = concealedSamples;
|
|
1495
|
+
rtc_stats.total_samples_received = totalSamplesReceived;
|
|
1496
|
+
} else {
|
|
1497
|
+
rtc_stats.frames_dropped = framesDropped;
|
|
1498
|
+
rtc_stats.iframes_decoded = keyFramesDecoded;
|
|
1499
|
+
rtc_stats.video_bytes_received = bytesReceived - (_this5.cacheRtcStats.videoBytesReceived || 0);
|
|
1500
|
+
_this5.cacheRtcStats.videoBytesReceived = bytesReceived;
|
|
1501
|
+
rtc_stats.video_dec_time = totalDecodeTime;
|
|
1502
|
+
rtc_stats.video_decoded_delay_ms = rtc_stats.video_dec_elapse / framesDecoded;
|
|
1503
|
+
rtc_stats.video_frame_height = frameHeight;
|
|
1504
|
+
rtc_stats.video_frame_width = frameWidth;
|
|
1505
|
+
if (_this5.cacheRtcStats.framesDecoded !== void 0) {
|
|
1506
|
+
rtc_stats.video_decode_framerate = (framesDecoded - _this5.cacheRtcStats.framesDecoded) / duration;
|
|
1507
|
+
}
|
|
1508
|
+
_this5.cacheRtcStats.framesDecoded = framesDecoded;
|
|
1509
|
+
if (_this5.cacheRtcStats.framesReceived !== void 0) {
|
|
1510
|
+
rtc_stats.video_recv_framerate = (framesReceived - _this5.cacheRtcStats.framesReceived) / duration;
|
|
1511
|
+
}
|
|
1512
|
+
if (_this5.cacheRtcStats.freezeCount !== void 0) {
|
|
1513
|
+
rtc_stats.freeze_count = freezeCount - _this5.cacheRtcStats.freezeCount;
|
|
1514
|
+
rtc_stats.freeze_duration = totalFreezesDuration - _this5.cacheRtcStats.totalFreezesDuration;
|
|
1515
|
+
}
|
|
1516
|
+
_this5.cacheRtcStats.freezeCount = freezeCount;
|
|
1517
|
+
_this5.cacheRtcStats.totalFreezesDuration = totalFreezesDuration;
|
|
1518
|
+
_this5.cacheRtcStats.framesReceived = framesReceived;
|
|
1519
|
+
rtc_stats.total_pauses_duration = totalPausesDuration;
|
|
1520
|
+
rtc_stats.video_jb_delay = jitterBufferDelay / jitterBufferEmittedCount * 1e3;
|
|
1521
|
+
rtc_stats.video_jitter = jitter * 1e3;
|
|
1522
|
+
rtc_stats.video_nack_count = nackCount;
|
|
1523
|
+
rtc_stats.video_packets_lost = packetsLost - (_this5.cacheRtcStats.videoPacketsLost || 0);
|
|
1524
|
+
rtc_stats.video_packets_received = packetsReceived - (_this5.cacheRtcStats.videoPacketsReceived || 0);
|
|
1525
|
+
rtc_stats.video_fraction_lost = rtc_stats.video_packets_lost / rtc_stats.video_packets_received;
|
|
1526
|
+
_this5.cacheRtcStats.videoPacketsLost = packetsLost;
|
|
1527
|
+
_this5.cacheRtcStats.videoPacketsReceived = packetsReceived;
|
|
1528
|
+
rtc_stats.video_pli_count = pliCount;
|
|
1529
|
+
rtc_stats.decoder_name = decoderImplementation;
|
|
1530
|
+
}
|
|
1531
|
+
break;
|
|
1532
|
+
case "remote-outbound-rtp":
|
|
1533
|
+
rtc_stats.e2e_delay_ms = timestamp - remoteTimestamp;
|
|
1534
|
+
break;
|
|
1535
|
+
case "track":
|
|
1536
|
+
if (frameWidth !== void 0) {
|
|
1537
|
+
rtc_stats.video_frame_width = frameWidth;
|
|
1538
|
+
rtc_stats.video_frame_height = frameHeight;
|
|
1539
|
+
}
|
|
1540
|
+
break;
|
|
1541
|
+
case "candidate-pair":
|
|
1542
|
+
rtc_stats.rtt = currentRoundTripTime * 1e3;
|
|
1543
|
+
break;
|
|
1544
|
+
case "codec":
|
|
1545
|
+
if (mimeType.includes("video")) {
|
|
1546
|
+
rtc_stats.video_codec = mimeType;
|
|
1547
|
+
} else {
|
|
1548
|
+
rtc_stats.audio_codec = mediaType;
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
rtc_stats.total_delay = rtc_stats.e2e_delay_ms + (rtc_stats.video_decoded_delay_ms || 0) + (rtc_stats.video_jb_delay || 0);
|
|
1552
|
+
});
|
|
1553
|
+
Object.assign(_this5.log.playing, {
|
|
1554
|
+
video_download_size: rtc_stats.video_bytes_received,
|
|
1555
|
+
decode_fps: rtc_stats.video_decode_framerate,
|
|
1556
|
+
sei_delay: rtc_stats.total_delay,
|
|
1557
|
+
sei_network_delay: rtc_stats.e2e_delay_ms,
|
|
1558
|
+
width: rtc_stats.video_frame_width,
|
|
1559
|
+
height: rtc_stats.video_frame_height,
|
|
1560
|
+
current_speed: (rtc_stats.audio_bytes_received + rtc_stats.video_bytes_received) / duration
|
|
1561
|
+
});
|
|
1562
|
+
return rtc_stats;
|
|
1563
|
+
});
|
|
1564
|
+
} catch (e3) {
|
|
1565
|
+
return Promise.reject(e3);
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
_proto2.reportPlaying = function reportPlaying(first) {
|
|
1569
|
+
try {
|
|
1570
|
+
var _this7 = this;
|
|
1571
|
+
if (_this7.commonParams.is_wasm) {
|
|
1572
|
+
_this7.commonParams.fps = _this7.player.video.fps;
|
|
1573
|
+
_this7.log.playing.render_fps = _this7.player.video.fps;
|
|
1574
|
+
_this7.log.playing.decode_fps = _this7.player.video.decodeFps;
|
|
1575
|
+
}
|
|
1576
|
+
_this7.log.playing.index++;
|
|
1577
|
+
var lastPlayingTime = _this7.log.playing.timestamp;
|
|
1578
|
+
var stallTime;
|
|
1579
|
+
if (_this7.inWaitingStart && _this7.inWaitingStart < getCurrentTime()) {
|
|
1580
|
+
stallTime = Math.min(_this7.options.playingInterval || _this7.log.playing.play_time, getCurrentTime() - Math.max(_this7.inWaitingStart, lastPlayingTime));
|
|
1581
|
+
}
|
|
1582
|
+
_this7.getPlayerQuality();
|
|
1583
|
+
_this7.getPlayerBuffer();
|
|
1584
|
+
if (!_this7.options.downloadSpeedInterval) {
|
|
1585
|
+
_this7.log.playing.current_speed = _this7.getPlayerDownloadSpeed();
|
|
1586
|
+
}
|
|
1587
|
+
var now2 = getCurrentTime();
|
|
1588
|
+
var playedTime = now2 - lastPlayingTime;
|
|
1589
|
+
var stall_time = (stallTime > 200 ? stallTime : 0) + _this7.log.playing.stall_time;
|
|
1590
|
+
var stall_count = (stallTime > 200 ? 1 : 0) + _this7.log.playing.stall_count;
|
|
1591
|
+
if (_this7.options.aggregationDowngradeStallTime) {
|
|
1592
|
+
_this7.log.playing.aggregation_downgrade_stall = (stallTime > _this7.options.aggregationDowngradeStallTime ? stallTime : 0) + (_this7.log.playing.aggregation_downgrade_stall || 0);
|
|
1593
|
+
}
|
|
1594
|
+
Object.assign(_this7.log.playing, _objectSpread2({
|
|
1595
|
+
timestamp: now2,
|
|
1596
|
+
// 60s内存在多次触发playing
|
|
1597
|
+
stop_time: now2,
|
|
1598
|
+
duration: first ? 0 : playedTime / 1e3,
|
|
1599
|
+
stall_time_per_100sec: stall_time / playedTime * 100,
|
|
1600
|
+
// 计算百秒卡顿时长
|
|
1601
|
+
stall_count_per_100sec: stall_count * 1e3 / playedTime * 100,
|
|
1602
|
+
// 计算百秒卡顿次数
|
|
1603
|
+
stall_count,
|
|
1604
|
+
// playing前会有一次卡顿现处于waiting状态
|
|
1605
|
+
stall_time,
|
|
1606
|
+
play_current_time: _this7.player.currentTime
|
|
1607
|
+
}, _this7.videoSize));
|
|
1608
|
+
return Promise.resolve(_this7.getRtcStats(playedTime, first)).then(function(stats) {
|
|
1609
|
+
_this7.logmanager.push(Object.assign({}, _this7.log.playing, _objectSpread2({
|
|
1610
|
+
play_time: first ? 0 : playedTime
|
|
1611
|
+
}, stats)), true);
|
|
1612
|
+
_this7.log.playing.download_speed_array = [];
|
|
1613
|
+
_this7.log.playing.stall_time = 0;
|
|
1614
|
+
_this7.log.playing.stall_count = 0;
|
|
1615
|
+
if (_this7.options.aggregationDowngradeStallTime) {
|
|
1616
|
+
_this7.log.playing.aggregation_downgrade_stall = 0;
|
|
1617
|
+
}
|
|
1618
|
+
});
|
|
1619
|
+
} catch (e3) {
|
|
1620
|
+
return Promise.reject(e3);
|
|
1621
|
+
}
|
|
1622
|
+
};
|
|
1623
|
+
_proto2.handlePlayerPlaying = function handlePlayerPlaying() {
|
|
1624
|
+
try {
|
|
1625
|
+
var _this9 = this;
|
|
1626
|
+
if (_this9.player && _this9.player.video.readyState < 3) {
|
|
1627
|
+
return Promise.resolve();
|
|
1628
|
+
}
|
|
1629
|
+
_this9.player.off("playing", _this9.handlePlayerPlaying);
|
|
1630
|
+
_this9.player.off("timeupdate", _this9.handlePlayerPlaying);
|
|
1631
|
+
if (_this9.core) {
|
|
1632
|
+
var _ref2 = _this9.core.getStats() || {}, fps = _ref2.fps;
|
|
1633
|
+
_this9.commonParams.fps = fps;
|
|
1634
|
+
}
|
|
1635
|
+
return Promise.resolve(_this9.reportPlaying(true)).then(function() {
|
|
1636
|
+
_this9.clearPlayingInterval();
|
|
1637
|
+
var timer = _this9.options.playingInterval || _this9.log.playing.play_time;
|
|
1638
|
+
_this9.intervalId = setInterval(function() {
|
|
1639
|
+
try {
|
|
1640
|
+
var _temp4 = function() {
|
|
1641
|
+
if (Math.abs(Date.now() - _this9.log.playing.timestamp - timer) < 100 || Date.now() - _this9.log.playing.timestamp >= timer) {
|
|
1642
|
+
var _temp5 = function() {
|
|
1643
|
+
if (!_this9.player.video) {
|
|
1644
|
+
_this9.destroyFunc();
|
|
1645
|
+
} else {
|
|
1646
|
+
var _temp6 = function() {
|
|
1647
|
+
if (_this9.player.paused) {
|
|
1648
|
+
_this9.handleVideopause();
|
|
1649
|
+
} else {
|
|
1650
|
+
return Promise.resolve(_this9.reportPlaying()).then(function() {
|
|
1651
|
+
});
|
|
1652
|
+
}
|
|
1653
|
+
}();
|
|
1654
|
+
if (_temp6 && _temp6.then)
|
|
1655
|
+
return _temp6.then(function() {
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
}();
|
|
1659
|
+
if (_temp5 && _temp5.then)
|
|
1660
|
+
return _temp5.then(function() {
|
|
1661
|
+
});
|
|
1662
|
+
}
|
|
1663
|
+
}();
|
|
1664
|
+
return Promise.resolve(_temp4 && _temp4.then ? _temp4.then(function() {
|
|
1665
|
+
}) : void 0);
|
|
1666
|
+
} catch (e3) {
|
|
1667
|
+
return Promise.reject(e3);
|
|
1668
|
+
}
|
|
1669
|
+
}, 1e3);
|
|
1670
|
+
_this9.clearStallTimer();
|
|
1671
|
+
_this9.handleVideoplaying();
|
|
1672
|
+
if (!_this9.started) {
|
|
1673
|
+
_this9.reportStartPlay();
|
|
1674
|
+
}
|
|
1675
|
+
_this9.saveBuffered();
|
|
1676
|
+
});
|
|
1677
|
+
} catch (e3) {
|
|
1678
|
+
return Promise.reject(e3);
|
|
1679
|
+
}
|
|
1680
|
+
};
|
|
1681
|
+
_proto2.handlePlayerReady = function handlePlayerReady() {
|
|
1682
|
+
var _this10 = this;
|
|
1683
|
+
this.log.start_play.start_play_time = getCurrentTime();
|
|
1684
|
+
if (this.player.config.autoplay) {
|
|
1685
|
+
this.reportStartPlay();
|
|
1686
|
+
}
|
|
1687
|
+
if (this.options.playResultThreshold) {
|
|
1688
|
+
this.log.play_result.threshold = this.options.playResultThreshold;
|
|
1689
|
+
}
|
|
1690
|
+
this.clearPlayResultTimer();
|
|
1691
|
+
this.log.play_result.start = getCurrentTime();
|
|
1692
|
+
this.playResultTimer = setTimeout(function() {
|
|
1693
|
+
if (_this10.log.play_result.timestamp >= _this10.log.play_result.start)
|
|
1694
|
+
return;
|
|
1695
|
+
_this10.log.play_result.is_threshold = 1;
|
|
1696
|
+
_this10.logmanager.push(_this10.log.play_result, true);
|
|
1697
|
+
}, this.log.play_result.threshold);
|
|
1698
|
+
};
|
|
1699
|
+
_proto2.handlePlayerWaiting = function handlePlayerWaiting() {
|
|
1700
|
+
var _this11 = this;
|
|
1701
|
+
if (!!this.inWaitingStart || !this.log.first_frame.timestamp)
|
|
1702
|
+
return;
|
|
1703
|
+
this.log.stall.timestamp = this.inWaitingStart = this.log.stall.stall_start = getCurrentTime();
|
|
1704
|
+
this.log.stall_start.ready_state = this.log.stall.ready_state = this.player.video.readyState;
|
|
1705
|
+
this.log.stall_start.timestamp = getCurrentTime();
|
|
1706
|
+
this.log.stall_start.stall_start_time = getCurrentTime();
|
|
1707
|
+
this.log.stall_start.video_buffer_time = this.player.video.readyState;
|
|
1708
|
+
this.log.stall_start.play_current_time = this.player.currentTime;
|
|
1709
|
+
this.log.stall.play_current_time = this.player.currentTime;
|
|
1710
|
+
this.log.stall_start.buffered = this.getBuffered();
|
|
1711
|
+
this.log.stall.buffered = this.log.stall_start.buffered;
|
|
1712
|
+
this.log.stall.current_speed = this.getPlayerDownloadSpeed();
|
|
1713
|
+
Object.assign(this.log.stall_start, this.videoSize);
|
|
1714
|
+
this.clearStallTimer();
|
|
1715
|
+
this.stallStartTimer = setTimeout(function() {
|
|
1716
|
+
_this11.logmanager.push(_this11.log.stall_start, true);
|
|
1717
|
+
}, 205);
|
|
1718
|
+
};
|
|
1719
|
+
_proto2.handleVideoseeking = function handleVideoseeking() {
|
|
1720
|
+
if (!this.player || !this.player.video)
|
|
1721
|
+
return;
|
|
1722
|
+
if (this.inWaitingStart && this.player.video.duration < Infinity) {
|
|
1723
|
+
this.inWaitingStart = 0;
|
|
1724
|
+
this.clearStallTimer();
|
|
1725
|
+
}
|
|
1726
|
+
};
|
|
1727
|
+
_proto2.handleVideoseeked = function handleVideoseeked() {
|
|
1728
|
+
if (!this.player || !this.player.video)
|
|
1729
|
+
return;
|
|
1730
|
+
if (this.inWaitingStart && this.player.video.duration < Infinity) {
|
|
1731
|
+
this.inWaitingStart = 0;
|
|
1732
|
+
this.log.play_stop.stall_count > 0 && this.log.play_stop.stall_count--;
|
|
1733
|
+
}
|
|
1734
|
+
};
|
|
1735
|
+
_proto2.handleVideoplay = function handleVideoplay() {
|
|
1736
|
+
this.reportStartPlay();
|
|
1737
|
+
this.removeVideoEvt("play", this.handleVideoplay);
|
|
1738
|
+
};
|
|
1739
|
+
_proto2.handleVideotimeupdate = function handleVideotimeupdate() {
|
|
1740
|
+
if (Math.abs(this.player.currentTime - this.log.stall_start.play_current_time) > 0.2) {
|
|
1741
|
+
this.stallEnd();
|
|
1742
|
+
}
|
|
1743
|
+
this.saveBuffered();
|
|
1744
|
+
};
|
|
1745
|
+
_proto2.handleVideocanplay = function handleVideocanplay() {
|
|
1746
|
+
this.stallEnd();
|
|
1747
|
+
this.reportFirstframe();
|
|
1748
|
+
};
|
|
1749
|
+
_proto2.handleVideoplaying = function handleVideoplaying() {
|
|
1750
|
+
this.stallEnd();
|
|
1751
|
+
this.log.play_stop.is_stream_received = 1;
|
|
1752
|
+
var currentTime = getCurrentTime();
|
|
1753
|
+
this.reportStartPlay();
|
|
1754
|
+
this.log.first_frame.start = currentTime;
|
|
1755
|
+
};
|
|
1756
|
+
_proto2.stallEnd = function stallEnd() {
|
|
1757
|
+
this.clearStallTimer();
|
|
1758
|
+
var currentTime = getCurrentTime();
|
|
1759
|
+
if (this.inWaitingStart) {
|
|
1760
|
+
var diff = currentTime - this.inWaitingStart;
|
|
1761
|
+
if (diff > 200) {
|
|
1762
|
+
this.log.play_stop.stall_count++;
|
|
1763
|
+
this.log.play_stop.stall_time += currentTime - this.inWaitingStart;
|
|
1764
|
+
this.log.playing.stall_time += currentTime - Math.max(this.inWaitingStart, this.log.playing.timestamp);
|
|
1765
|
+
this.log.stall.stall_end = currentTime;
|
|
1766
|
+
this.log.stall.timestamp = getCurrentTime();
|
|
1767
|
+
this.log.playing.stall_count++;
|
|
1768
|
+
Object.assign(this.log.stall, _objectSpread2({}, this.videoSize));
|
|
1769
|
+
this.logmanager.push(this.log.stall, true);
|
|
1770
|
+
}
|
|
1771
|
+
if (this.options.aggregationDowngradeStallTime && diff > this.options.aggregationDowngradeStallTime) {
|
|
1772
|
+
this.log.playing.aggregation_downgrade_stall = (this.log.playing.aggregation_downgrade_stall || 0) + (currentTime - Math.max(this.inWaitingStart, this.log.playing.timestamp));
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
this.inWaitingStart = 0;
|
|
1776
|
+
};
|
|
1777
|
+
_proto2.handleVideoloadeddata = function handleVideoloadeddata() {
|
|
1778
|
+
this.reportFirstframe();
|
|
1779
|
+
};
|
|
1780
|
+
_proto2.handleVideoratechange = function handleVideoratechange() {
|
|
1781
|
+
this.log.playing.speed_switch_count++;
|
|
1782
|
+
this.log.playing.speed_switch_info = this.player.video.playbackRate;
|
|
1783
|
+
};
|
|
1784
|
+
_proto2.handleVideoended = function handleVideoended() {
|
|
1785
|
+
this.clearPlayingInterval();
|
|
1786
|
+
this.clearStallTimer();
|
|
1787
|
+
Object.assign(this.log.playing, _objectSpread2({
|
|
1788
|
+
timestamp: getCurrentTime(),
|
|
1789
|
+
is_last: 1
|
|
1790
|
+
}, this.videoSize));
|
|
1791
|
+
this.logmanager.push(this.log.playing);
|
|
1792
|
+
};
|
|
1793
|
+
_proto2.handleVideoerror = function handleVideoerror() {
|
|
1794
|
+
var _this12 = this;
|
|
1795
|
+
this.errorNumber = 1;
|
|
1796
|
+
var error2 = this.player.video.error;
|
|
1797
|
+
var firstframeFailed = function firstframeFailed2() {
|
|
1798
|
+
if (_this12.log.first_frame.first_frame_view === 0 && !_this12.log.first_frame_failed.code) {
|
|
1799
|
+
if (error2) {
|
|
1800
|
+
_this12.log.first_frame_failed.code = error2.code;
|
|
1801
|
+
_this12.log.first_frame_failed.msg = video_error[error2.code];
|
|
1802
|
+
if (_this12.log.first_frame_failed.timestamp !== void 0) {
|
|
1803
|
+
_this12.log.first_frame_failed.timestamp = getCurrentTime();
|
|
1804
|
+
}
|
|
1805
|
+
_this12.logmanager.push(_this12.log.first_frame_failed, true);
|
|
1806
|
+
if (!_this12.log.play_result.is_threshold) {
|
|
1807
|
+
_this12.log.play_result.reason = video_error[error2.code] || "first frame failed";
|
|
1808
|
+
_this12.log.play_result.code = error2.code;
|
|
1809
|
+
_this12.clearPlayResultTimer();
|
|
1810
|
+
_this12.logmanager.push(_this12.log.play_result, true);
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
if (_this12.options.error_report_stop) {
|
|
1815
|
+
_this12.handleUserLeave();
|
|
1816
|
+
} else {
|
|
1817
|
+
_this12.updatePlayStopParams();
|
|
1818
|
+
}
|
|
1819
|
+
};
|
|
1820
|
+
Object.assign(this.log.play_error, _objectSpread2(_objectSpread2({
|
|
1821
|
+
timestamp: getCurrentTime()
|
|
1822
|
+
}, this.videoSize), error2 && {
|
|
1823
|
+
code: error2.code,
|
|
1824
|
+
info: error2.message
|
|
1825
|
+
}));
|
|
1826
|
+
this.logmanager.push(this.log.play_error, true);
|
|
1827
|
+
firstframeFailed();
|
|
1828
|
+
};
|
|
1829
|
+
_proto2.handleVideopause = function handleVideopause() {
|
|
1830
|
+
this.stallEnd();
|
|
1831
|
+
this.clearPlayingInterval();
|
|
1832
|
+
this.clearStallTimer();
|
|
1833
|
+
clearTimeout(this.collectDownloadSpeedTimer);
|
|
1834
|
+
this.player.once("playing", this.handlePlayerPlaying);
|
|
1835
|
+
this.player.once("timeupdate", this.handlePlayerPlaying);
|
|
1836
|
+
};
|
|
1837
|
+
_proto2.destroyFunc = function destroyFunc(no_report_stop) {
|
|
1838
|
+
var _this13 = this;
|
|
1839
|
+
if (this.destroyed) {
|
|
1840
|
+
return;
|
|
1841
|
+
}
|
|
1842
|
+
if (!no_report_stop) {
|
|
1843
|
+
this.handleUserLeave();
|
|
1844
|
+
}
|
|
1845
|
+
this.destroyed = true;
|
|
1846
|
+
if (sniffer.device === "pc") {
|
|
1847
|
+
window.removeEventListener("beforeunload", this.handleUserLeave);
|
|
1848
|
+
} else if (sniffer.device === "mobile") {
|
|
1849
|
+
window.removeEventListener("pagehide", this.handleUserLeave);
|
|
1850
|
+
}
|
|
1851
|
+
videoEvts.forEach(function(name) {
|
|
1852
|
+
_this13.removeVideoEvt(name, _this13["handleVideo" + name + "Evt"]);
|
|
1853
|
+
});
|
|
1854
|
+
if (this.player) {
|
|
1855
|
+
if (this.player._start) {
|
|
1856
|
+
this.player.start = this.player._start;
|
|
1857
|
+
delete this.player._start;
|
|
1858
|
+
}
|
|
1859
|
+
this.player.off("destroy", this.destroyFunc);
|
|
1860
|
+
this.player.off("complete", this.handlePlayerComlete);
|
|
1861
|
+
this.player.off("playing", this.handlePlayerPlaying);
|
|
1862
|
+
this.player.off("timeupdate", this.handlePlayerPlaying);
|
|
1863
|
+
this.player.off("ready", this.handlePlayerReady);
|
|
1864
|
+
this.player.off("waiting", this.handlePlayerWaiting);
|
|
1865
|
+
this.player.off("largeavgap", this.handleAVUnsync);
|
|
1866
|
+
this.player.off("error", this.handlePlayerError);
|
|
1867
|
+
this.player.off("SEI_PARSED", this.handleSEIParsed);
|
|
1868
|
+
this.player.off("pause", this.handlePlayerPause);
|
|
1869
|
+
this.player.off("ttfb", this.handleTTFB);
|
|
1870
|
+
this.player.off("urlchange", this.handleUrlChange);
|
|
1871
|
+
this.player.off("isKeyframe", this.handleKeyframe);
|
|
1872
|
+
this.player.off("sourceopen", this.handleSourceOpen);
|
|
1873
|
+
this.player.off("bufferappend", this.handleBufferAppend);
|
|
1874
|
+
this.player.off("core_event", this.handleCoreEvent);
|
|
1875
|
+
this.player.off("degrade", this.handleDegrade);
|
|
1876
|
+
this.clearPlayingInterval();
|
|
1877
|
+
this.clearStallTimer();
|
|
1878
|
+
this.clearPlayResultTimer();
|
|
1879
|
+
clearTimeout(this.collectDownloadSpeedTimer);
|
|
1880
|
+
this._player = null;
|
|
1881
|
+
}
|
|
1882
|
+
};
|
|
1883
|
+
_proto2.handleUserLeave = function handleUserLeave() {
|
|
1884
|
+
if (this.destroyed || !this.started) {
|
|
1885
|
+
return;
|
|
1886
|
+
}
|
|
1887
|
+
this.destroyed = true;
|
|
1888
|
+
this.updatePlayStopParams();
|
|
1889
|
+
this.reportPlayStop();
|
|
1890
|
+
this.clearPlayingInterval();
|
|
1891
|
+
this.clearStallTimer();
|
|
1892
|
+
clearTimeout(this.collectDownloadSpeedTimer);
|
|
1893
|
+
this.removeWindowListener();
|
|
1894
|
+
};
|
|
1895
|
+
_proto2.saveBuffered = function saveBuffered() {
|
|
1896
|
+
try {
|
|
1897
|
+
var buffered = this.getBuffered();
|
|
1898
|
+
if (buffered && buffered.length) {
|
|
1899
|
+
this.log.play_stop.buffered = buffered;
|
|
1900
|
+
}
|
|
1901
|
+
} catch (error2) {
|
|
1902
|
+
}
|
|
1903
|
+
};
|
|
1904
|
+
_proto2.getBuffered = function getBuffered() {
|
|
1905
|
+
try {
|
|
1906
|
+
var buffered = [];
|
|
1907
|
+
var video = this.player.video;
|
|
1908
|
+
for (var i2 = 0; i2 < video.buffered.length; i2++) {
|
|
1909
|
+
buffered.push([video.buffered.start(i2), video.buffered.end(i2)]);
|
|
1910
|
+
}
|
|
1911
|
+
return buffered;
|
|
1912
|
+
} catch (error2) {
|
|
1913
|
+
}
|
|
1914
|
+
};
|
|
1915
|
+
_proto2.reportPlayStop = function reportPlayStop() {
|
|
1916
|
+
this.log.play_stop.play_current_time = this.player.currentTime || this.log.playing.play_current_time;
|
|
1917
|
+
this.saveBuffered();
|
|
1918
|
+
this.logmanager.push(this.log.play_stop, true);
|
|
1919
|
+
};
|
|
1920
|
+
_proto2.reportFirstframe = function reportFirstframe() {
|
|
1921
|
+
if (this.firstFrameViewed) {
|
|
1922
|
+
return;
|
|
1923
|
+
}
|
|
1924
|
+
if (this.core) {
|
|
1925
|
+
var _ref3 = this.core.getStats() || {}, fps = _ref3.fps;
|
|
1926
|
+
this.commonParams.fps = fps;
|
|
1927
|
+
}
|
|
1928
|
+
this.firstFrameViewed = true;
|
|
1929
|
+
var currentTime = getCurrentTime();
|
|
1930
|
+
Object.assign(this.log.first_frame, _objectSpread2({
|
|
1931
|
+
first_frame_view: currentTime - this.log.start_play.start_play_time || currentTime,
|
|
1932
|
+
timestamp: currentTime
|
|
1933
|
+
}, this.videoSize));
|
|
1934
|
+
if (this.log.first_frame.ttfb_end) {
|
|
1935
|
+
this.log.first_frame.ttdb = currentTime - this.log.first_frame.ttfb_end;
|
|
1936
|
+
}
|
|
1937
|
+
this.logmanager.push(this.log.first_frame, true);
|
|
1938
|
+
this.clearPlayResultTimer();
|
|
1939
|
+
this.log.play_result.result = 1;
|
|
1940
|
+
this.logmanager.push(this.log.play_result, true);
|
|
1941
|
+
this.log.play_stop.is_stream_received = 1;
|
|
1942
|
+
};
|
|
1943
|
+
_proto2.updatePlayStopParams = function updatePlayStopParams() {
|
|
1944
|
+
var timing = getResourceTiming(this._url);
|
|
1945
|
+
var endTime = getCurrentTime();
|
|
1946
|
+
this.playedTime = endTime - this.log.start_play.start_play_time;
|
|
1947
|
+
var play_stop = this.log.play_stop;
|
|
1948
|
+
Object.assign(play_stop, _objectSpread2({}, play_stop.stall_count === 0 && {
|
|
1949
|
+
stall_time: 0
|
|
1950
|
+
}));
|
|
1951
|
+
if (this.inWaitingStart && endTime - this.inWaitingStart > 200) {
|
|
1952
|
+
play_stop.stall_time += endTime - this.inWaitingStart;
|
|
1953
|
+
}
|
|
1954
|
+
this.inWaitingStart = 0;
|
|
1955
|
+
Object.assign(play_stop, _objectSpread2({
|
|
1956
|
+
stall_time_per_100sec: play_stop.stall_time / this.playedTime * 100,
|
|
1957
|
+
// 计算百秒卡顿时长
|
|
1958
|
+
stall_count_per_100sec: play_stop.stall_count * 1e3 / this.playedTime * 100
|
|
1959
|
+
}, timing));
|
|
1960
|
+
if (this.log.play_stop.stall_count_per_100sec === 0) {
|
|
1961
|
+
this.log.play_stop.stall_time_per_100sec = 0;
|
|
1962
|
+
}
|
|
1963
|
+
if (this.log.play_stop.stall_time_per_100sec > 100 || this.log.play_stop.stall_time_per_100sec < 0) {
|
|
1964
|
+
return;
|
|
1965
|
+
}
|
|
1966
|
+
if (this.log.playing.index) {
|
|
1967
|
+
Object.assign(this.log.playing, _objectSpread2({
|
|
1968
|
+
timestamp: getCurrentTime(),
|
|
1969
|
+
is_last: 1
|
|
1970
|
+
}, this.videoSize));
|
|
1971
|
+
this.logmanager.push(this.log.playing, true);
|
|
1972
|
+
} else {
|
|
1973
|
+
this.log.play_stop.error_code = this.log.play_error.code;
|
|
1974
|
+
this.log.play_stop.error_info = this.log.play_error.info;
|
|
1975
|
+
}
|
|
1976
|
+
endTime = getCurrentTime();
|
|
1977
|
+
Object.assign(play_stop, _objectSpread2({
|
|
1978
|
+
timestamp: endTime,
|
|
1979
|
+
stop_time: endTime,
|
|
1980
|
+
duration: this.playedTime / 1e3,
|
|
1981
|
+
play_time: this.playedTime / 1e3
|
|
1982
|
+
}, this.videoSize));
|
|
1983
|
+
if (this.errorNumber === 0) {
|
|
1984
|
+
play_stop.play_time_on_no_frame = play_stop.stop_time - this.log.start_play.start_play_time;
|
|
1985
|
+
}
|
|
1986
|
+
};
|
|
1987
|
+
_proto2.clearPlayingInterval = function clearPlayingInterval() {
|
|
1988
|
+
if (this.intervalId) {
|
|
1989
|
+
clearInterval(this.intervalId);
|
|
1990
|
+
this.intervalId = null;
|
|
1991
|
+
}
|
|
1992
|
+
};
|
|
1993
|
+
_proto2.clearStallTimer = function clearStallTimer() {
|
|
1994
|
+
clearTimeout(this.stallStartTimer);
|
|
1995
|
+
};
|
|
1996
|
+
_proto2.clearPlayResultTimer = function clearPlayResultTimer() {
|
|
1997
|
+
clearTimeout(this.playResultTimer);
|
|
1998
|
+
};
|
|
1999
|
+
_proto2.destroy = function destroy(report_stop) {
|
|
2000
|
+
this.destroyFunc(!report_stop);
|
|
2001
|
+
};
|
|
2002
|
+
_proto2.bindVideoEvt = function bindVideoEvt(name, handleFunc) {
|
|
2003
|
+
if (!this.player)
|
|
2004
|
+
return;
|
|
2005
|
+
this.player.video.addEventListener(name, handleFunc, false);
|
|
2006
|
+
};
|
|
2007
|
+
_proto2.removeVideoEvt = function removeVideoEvt(name, handleFunc) {
|
|
2008
|
+
if (!this.player || !this.player.video)
|
|
2009
|
+
return;
|
|
2010
|
+
this.player.video.removeEventListener(name, handleFunc, false);
|
|
2011
|
+
};
|
|
2012
|
+
_proto2.send = function send(log, retryTime) {
|
|
2013
|
+
this.logmanager.send(log, retryTime);
|
|
2014
|
+
};
|
|
2015
|
+
return XgLiveLogger2;
|
|
2016
|
+
}();
|
|
2017
|
+
var e = function() {
|
|
2018
|
+
return e = Object.assign || function(e3) {
|
|
2019
|
+
for (var t2, i2 = 1, n2 = arguments.length; i2 < n2; i2++)
|
|
2020
|
+
for (var o2 in t2 = arguments[i2])
|
|
2021
|
+
Object.prototype.hasOwnProperty.call(t2, o2) && (e3[o2] = t2[o2]);
|
|
2022
|
+
return e3;
|
|
2023
|
+
}, e.apply(this, arguments);
|
|
2024
|
+
};
|
|
2025
|
+
function t(e3, t2) {
|
|
2026
|
+
var i2 = "function" == typeof Symbol && e3[Symbol.iterator];
|
|
2027
|
+
if (!i2)
|
|
2028
|
+
return e3;
|
|
2029
|
+
var n2, o2, r2 = i2.call(e3), s2 = [];
|
|
2030
|
+
try {
|
|
2031
|
+
for (; (void 0 === t2 || t2-- > 0) && !(n2 = r2.next()).done; )
|
|
2032
|
+
s2.push(n2.value);
|
|
2033
|
+
} catch (e4) {
|
|
2034
|
+
o2 = { error: e4 };
|
|
2035
|
+
} finally {
|
|
2036
|
+
try {
|
|
2037
|
+
n2 && !n2.done && (i2 = r2.return) && i2.call(r2);
|
|
2038
|
+
} finally {
|
|
2039
|
+
if (o2)
|
|
2040
|
+
throw o2.error;
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
return s2;
|
|
2044
|
+
}
|
|
2045
|
+
function i() {
|
|
2046
|
+
for (var e3 = [], i2 = 0; i2 < arguments.length; i2++)
|
|
2047
|
+
e3 = e3.concat(t(arguments[i2]));
|
|
2048
|
+
return e3;
|
|
2049
|
+
}
|
|
2050
|
+
var n, o = function() {
|
|
2051
|
+
function e3() {
|
|
2052
|
+
this._hooks = {}, this._cache = [], this._hooksCache = {};
|
|
2053
|
+
}
|
|
2054
|
+
return e3.prototype.on = function(e4, t2) {
|
|
2055
|
+
e4 && t2 && "function" == typeof t2 && (this._hooks[e4] || (this._hooks[e4] = []), this._hooks[e4].push(t2));
|
|
2056
|
+
}, e3.prototype.once = function(e4, t2) {
|
|
2057
|
+
var i2 = this;
|
|
2058
|
+
if (e4 && t2 && "function" == typeof t2) {
|
|
2059
|
+
this.on(e4, function n2(o2) {
|
|
2060
|
+
t2(o2), i2.off(e4, n2);
|
|
2061
|
+
});
|
|
2062
|
+
}
|
|
2063
|
+
}, e3.prototype.off = function(e4, t2) {
|
|
2064
|
+
if (e4 && this._hooks[e4] && this._hooks[e4].length)
|
|
2065
|
+
if (t2) {
|
|
2066
|
+
var i2 = this._hooks[e4].indexOf(t2);
|
|
2067
|
+
-1 !== i2 && this._hooks[e4].splice(i2, 1);
|
|
2068
|
+
} else
|
|
2069
|
+
this._hooks[e4] = [];
|
|
2070
|
+
}, e3.prototype.emit = function(e4, t2, i2) {
|
|
2071
|
+
if (i2) {
|
|
2072
|
+
if (!e4)
|
|
2073
|
+
return;
|
|
2074
|
+
-1 !== this._cache.indexOf(i2) ? this._emit(e4, t2) : (this._hooksCache.hasOwnProperty(i2) || (this._hooksCache[i2] = {}), this._hooksCache[i2].hasOwnProperty(e4) || (this._hooksCache[i2][e4] = []), this._hooksCache[i2][e4].push(t2));
|
|
2075
|
+
} else
|
|
2076
|
+
this._emit(e4, t2);
|
|
2077
|
+
}, e3.prototype._emit = function(e4, t2) {
|
|
2078
|
+
e4 && this._hooks[e4] && this._hooks[e4].length && i(this._hooks[e4]).forEach(function(e5) {
|
|
2079
|
+
try {
|
|
2080
|
+
e5(t2);
|
|
2081
|
+
} catch (e6) {
|
|
2082
|
+
}
|
|
2083
|
+
});
|
|
2084
|
+
}, e3.prototype.set = function(e4) {
|
|
2085
|
+
e4 && -1 === this._cache.indexOf(e4) && this._cache.push(e4);
|
|
2086
|
+
}, e3;
|
|
2087
|
+
}(), r = function(e3) {
|
|
2088
|
+
return null != e3 && "[object Object]" == Object.prototype.toString.call(e3);
|
|
2089
|
+
}, s = (n = +Date.now() + Number(("" + Math.random()).slice(2, 8)), function() {
|
|
2090
|
+
return n += 1;
|
|
2091
|
+
}), a = function(e3) {
|
|
2092
|
+
return function(e4, t2, i2) {
|
|
2093
|
+
if ("string" == typeof e4 && "number" == typeof t2 && "number" == typeof i2) {
|
|
2094
|
+
var n2, o2 = [];
|
|
2095
|
+
i2 = i2 <= 25 ? i2 : i2 % 25;
|
|
2096
|
+
var r2 = String.fromCharCode(i2 + 97);
|
|
2097
|
+
n2 = e4.split(r2);
|
|
2098
|
+
for (var s2 = 0; s2 < n2.length; s2++) {
|
|
2099
|
+
var a2 = parseInt(n2[s2], i2);
|
|
2100
|
+
a2 = 1 * a2 ^ t2;
|
|
2101
|
+
var c2 = String.fromCharCode(a2);
|
|
2102
|
+
o2.push(c2);
|
|
2103
|
+
}
|
|
2104
|
+
return o2.join("");
|
|
2105
|
+
}
|
|
2106
|
+
}(e3, 64, 25);
|
|
2107
|
+
}, c = function(e3) {
|
|
2108
|
+
var t2 = document.createElement("a");
|
|
2109
|
+
return t2.href = e3, t2;
|
|
2110
|
+
}, h = function() {
|
|
2111
|
+
function e3(e4) {
|
|
2112
|
+
this.appid = e4, this.userAgent = window.navigator.userAgent, this.appVersion = window.navigator.appVersion;
|
|
2113
|
+
}
|
|
2114
|
+
return e3.prototype.init = function() {
|
|
2115
|
+
var e4 = window.navigator.userAgent, t2 = window.navigator.language, i2 = document.referrer, n2 = i2 ? c(i2).hostname : "";
|
|
2116
|
+
!function(e5) {
|
|
2117
|
+
var t3 = {};
|
|
2118
|
+
try {
|
|
2119
|
+
var i3 = c(e5).search;
|
|
2120
|
+
(i3 = i3.slice(1)).split("&").forEach(function(e6) {
|
|
2121
|
+
var i4, n3, o3 = e6.split("=");
|
|
2122
|
+
o3.length && (i4 = o3[0], n3 = o3[1]);
|
|
2123
|
+
try {
|
|
2124
|
+
t3[i4] = decodeURIComponent(void 0 === n3 ? "" : n3);
|
|
2125
|
+
} catch (e7) {
|
|
2126
|
+
t3[i4] = n3;
|
|
2127
|
+
}
|
|
2128
|
+
});
|
|
2129
|
+
} catch (e6) {
|
|
2130
|
+
}
|
|
2131
|
+
}(window.location.href);
|
|
2132
|
+
var o2 = /Mobile|htc|mini|Android|iP(ad|od|hone)/.test(this.appVersion) ? "wap" : "web", r2 = this.browser(), s2 = this.os();
|
|
2133
|
+
return { browser: r2.browser, browser_version: r2.browser_version, platform: o2, os_name: s2.os_name, os_version: s2.os_version, userAgent: e4, screen_width: window.screen && window.screen.width, screen_height: window.screen && window.screen.height, device_model: this.getDeviceModel(s2.os_name), language: t2, referrer: i2, referrer_host: n2 };
|
|
2134
|
+
}, e3.prototype.browser = function() {
|
|
2135
|
+
var e4, t2, i2 = "", n2 = "" + parseFloat(this.appVersion), o2 = this.userAgent;
|
|
2136
|
+
return -1 !== o2.indexOf("Edge") || -1 !== o2.indexOf("Edg") ? (i2 = "Microsoft Edge", -1 !== o2.indexOf("Edge") ? (e4 = o2.indexOf("Edge"), n2 = o2.substring(e4 + 5)) : (e4 = o2.indexOf("Edg"), n2 = o2.substring(e4 + 4))) : -1 !== (e4 = o2.indexOf("MSIE")) ? (i2 = "Microsoft Internet Explorer", n2 = o2.substring(e4 + 5)) : -1 !== (e4 = o2.indexOf("Lark")) ? (i2 = "Lark", n2 = o2.substring(e4 + 5, e4 + 11)) : -1 !== (e4 = o2.indexOf("MetaSr")) ? (i2 = "sougoubrowser", n2 = o2.substring(e4 + 7, e4 + 10)) : -1 !== o2.indexOf("MQQBrowser") || -1 !== o2.indexOf("QQBrowser") ? (i2 = "qqbrowser", -1 !== o2.indexOf("MQQBrowser") ? (e4 = o2.indexOf("MQQBrowser"), n2 = o2.substring(e4 + 11, e4 + 15)) : -1 !== o2.indexOf("QQBrowser") && (e4 = o2.indexOf("QQBrowser"), n2 = o2.substring(e4 + 10, e4 + 17))) : -1 !== o2.indexOf("Chrome") ? -1 !== (e4 = o2.indexOf("MicroMessenger")) ? (i2 = "weixin", n2 = o2.substring(e4 + 15, e4 + 20)) : -1 !== (e4 = o2.indexOf("360")) ? (i2 = "360browser", n2 = o2.substring(o2.indexOf("Chrome") + 7)) : -1 !== o2.indexOf("baidubrowser") || -1 !== o2.indexOf("BIDUBrowser") ? (-1 !== o2.indexOf("baidubrowser") ? (e4 = o2.indexOf("baidubrowser"), n2 = o2.substring(e4 + 13, e4 + 16)) : -1 !== o2.indexOf("BIDUBrowser") && (e4 = o2.indexOf("BIDUBrowser"), n2 = o2.substring(e4 + 12, e4 + 15)), i2 = "baidubrowser") : -1 !== (e4 = o2.indexOf("xiaomi")) ? -1 !== o2.indexOf("openlanguagexiaomi") ? (i2 = "openlanguage xiaomi", n2 = o2.substring(e4 + 7, e4 + 13)) : (i2 = "xiaomi", n2 = o2.substring(e4 - 7, e4 - 1)) : -1 !== (e4 = o2.indexOf("TTWebView")) ? (i2 = "TTWebView", n2 = o2.substring(e4 + 10, e4 + 23)) : (-1 !== (e4 = o2.indexOf("Chrome")) || -1 !== (e4 = o2.indexOf("Chrome"))) && (i2 = "Chrome", n2 = o2.substring(e4 + 7)) : -1 !== o2.indexOf("Safari") ? -1 !== (e4 = o2.indexOf("QQ")) ? (i2 = "qqbrowser", n2 = o2.substring(e4 + 10, e4 + 16)) : -1 !== (e4 = o2.indexOf("Safari")) && (i2 = "Safari", n2 = o2.substring(e4 + 7), -1 !== (e4 = o2.indexOf("Version")) && (n2 = o2.substring(e4 + 8))) : -1 !== (e4 = o2.indexOf("Firefox")) ? (i2 = "Firefox", n2 = o2.substring(e4 + 8)) : -1 !== (e4 = o2.indexOf("MicroMessenger")) ? (i2 = "weixin", n2 = o2.substring(e4 + 15, e4 + 20)) : -1 !== (e4 = o2.indexOf("QQ")) ? (i2 = "qqbrowser", n2 = o2.substring(e4 + 3, e4 + 8)) : -1 !== (e4 = o2.indexOf("Opera")) && (i2 = "Opera", n2 = o2.substring(e4 + 6), -1 !== (e4 = o2.indexOf("Version")) && (n2 = o2.substring(e4 + 8))), -1 !== (t2 = n2.indexOf(";")) && (n2 = n2.substring(0, t2)), -1 !== (t2 = n2.indexOf(" ")) && (n2 = n2.substring(0, t2)), -1 !== (t2 = n2.indexOf(")")) && (n2 = n2.substring(0, t2)), { browser: i2, browser_version: n2 };
|
|
2137
|
+
}, e3.prototype.os = function() {
|
|
2138
|
+
for (var e4 = "", t2 = "", i2 = [{ s: "Windows 10", r: /(Windows 10.0|Windows NT 10.0|Windows NT 10.1)/ }, { s: "Windows 8.1", r: /(Windows 8.1|Windows NT 6.3)/ }, { s: "Windows 8", r: /(Windows 8|Windows NT 6.2)/ }, { s: "Windows 7", r: /(Windows 7|Windows NT 6.1)/ }, { s: "Android", r: /Android/ }, { s: "Sun OS", r: /SunOS/ }, { s: "Linux", r: /(Linux|X11)/ }, { s: "iOS", r: /(iPhone|iPad|iPod)/ }, { s: "Mac OS X", r: /Mac OS X/ }, { s: "Mac OS", r: /(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/ }], n2 = 0; n2 < i2.length; n2++) {
|
|
2139
|
+
var o2 = i2[n2];
|
|
2140
|
+
if (o2.r.test(this.userAgent)) {
|
|
2141
|
+
"Mac OS X" === (e4 = o2.s) && this.isNewIpad() && (e4 = "iOS");
|
|
2142
|
+
break;
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
var r2 = function(e5, t3) {
|
|
2146
|
+
var i3 = e5.exec(t3);
|
|
2147
|
+
return i3 && i3[1] ? i3[1] : "";
|
|
2148
|
+
}, s2 = function(e5, t3) {
|
|
2149
|
+
var i3 = RegExp("(?:^|[^A-Z0-9-_]|[^A-Z0-9-]_|sprd-)(?:" + e5 + ")", "i").exec(t3);
|
|
2150
|
+
return i3 ? i3.slice(1)[0] : "";
|
|
2151
|
+
};
|
|
2152
|
+
/Windows/.test(e4) && (t2 = r2(/Windows (.*)/, e4), e4 = "windows");
|
|
2153
|
+
var a2, c2;
|
|
2154
|
+
switch (e4) {
|
|
2155
|
+
case "Mac OS X":
|
|
2156
|
+
t2 = s2("Mac[ +]OS[ +]X(?:[ /](?:Version )?(\\d+(?:[_\\.]\\d+)+))?", this.userAgent), e4 = "mac";
|
|
2157
|
+
break;
|
|
2158
|
+
case "Android":
|
|
2159
|
+
a2 = this.userAgent, (c2 = r2(/Android ([\.\_\d]+)/, a2)) || (c2 = r2(/Android\/([\.\_\d]+)/, a2)), t2 = c2, e4 = "android";
|
|
2160
|
+
break;
|
|
2161
|
+
case "iOS":
|
|
2162
|
+
t2 = this.isNewIpad() ? s2("Mac[ +]OS[ +]X(?:[ /](?:Version )?(\\d+(?:[_\\.]\\d+)+))?", this.userAgent) : (t2 = /OS (\d+)_(\d+)_?(\d+)?/.exec(this.appVersion)) ? t2[1] + "." + t2[2] + "." + (0 | t2[3]) : "", e4 = "ios";
|
|
2163
|
+
}
|
|
2164
|
+
return { os_name: e4, os_version: t2 };
|
|
2165
|
+
}, e3.prototype.getDeviceModel = function(e4) {
|
|
2166
|
+
var t2 = "";
|
|
2167
|
+
try {
|
|
2168
|
+
if ("android" === e4)
|
|
2169
|
+
navigator.userAgent.split(";").forEach(function(e5) {
|
|
2170
|
+
e5.indexOf("Build/") > -1 && (t2 = e5.slice(0, e5.indexOf("Build/")));
|
|
2171
|
+
});
|
|
2172
|
+
else if ("ios" === e4 || "mac" === e4 || "windows" === e4)
|
|
2173
|
+
if (this.isNewIpad())
|
|
2174
|
+
t2 = "iPad";
|
|
2175
|
+
else {
|
|
2176
|
+
var i2 = navigator.userAgent.replace("Mozilla/5.0 (", ""), n2 = i2.indexOf(";");
|
|
2177
|
+
t2 = i2.slice(0, n2);
|
|
2178
|
+
}
|
|
2179
|
+
} catch (e5) {
|
|
2180
|
+
return t2.trim();
|
|
2181
|
+
}
|
|
2182
|
+
return t2.trim();
|
|
2183
|
+
}, e3.prototype.isNewIpad = function() {
|
|
2184
|
+
return void 0 !== this.userAgent && "MacIntel" === navigator.platform && "number" == typeof navigator.maxTouchPoints && navigator.maxTouchPoints > 1;
|
|
2185
|
+
}, e3;
|
|
2186
|
+
}();
|
|
2187
|
+
var u, p, f = (u = function(e3, t2) {
|
|
2188
|
+
e3.exports = function() {
|
|
2189
|
+
function e4(e5) {
|
|
2190
|
+
for (var t4 = 1; t4 < arguments.length; t4++) {
|
|
2191
|
+
var i2 = arguments[t4];
|
|
2192
|
+
for (var n2 in i2)
|
|
2193
|
+
e5[n2] = i2[n2];
|
|
2194
|
+
}
|
|
2195
|
+
return e5;
|
|
2196
|
+
}
|
|
2197
|
+
function t3(i2, n2) {
|
|
2198
|
+
function o2(t4, o3, r3) {
|
|
2199
|
+
if ("undefined" != typeof document) {
|
|
2200
|
+
"number" == typeof (r3 = e4({}, n2, r3)).expires && (r3.expires = new Date(Date.now() + 864e5 * r3.expires)), r3.expires && (r3.expires = r3.expires.toUTCString()), t4 = encodeURIComponent(t4).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
|
|
2201
|
+
var s2 = "";
|
|
2202
|
+
for (var a2 in r3)
|
|
2203
|
+
r3[a2] && (s2 += "; " + a2, true !== r3[a2] && (s2 += "=" + r3[a2].split(";")[0]));
|
|
2204
|
+
return document.cookie = t4 + "=" + i2.write(o3, t4) + s2;
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
function r2(e5) {
|
|
2208
|
+
if ("undefined" != typeof document && (!arguments.length || e5)) {
|
|
2209
|
+
for (var t4 = document.cookie ? document.cookie.split("; ") : [], n3 = {}, o3 = 0; o3 < t4.length; o3++) {
|
|
2210
|
+
var r3 = t4[o3].split("="), s2 = r3.slice(1).join("=");
|
|
2211
|
+
try {
|
|
2212
|
+
var a2 = decodeURIComponent(r3[0]);
|
|
2213
|
+
if (n3[a2] = i2.read(s2, a2), e5 === a2)
|
|
2214
|
+
break;
|
|
2215
|
+
} catch (e6) {
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
return e5 ? n3[e5] : n3;
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
return Object.create({ set: o2, get: r2, remove: function(t4, i3) {
|
|
2222
|
+
o2(t4, "", e4({}, i3, { expires: -1 }));
|
|
2223
|
+
}, withAttributes: function(i3) {
|
|
2224
|
+
return t3(this.converter, e4({}, this.attributes, i3));
|
|
2225
|
+
}, withConverter: function(i3) {
|
|
2226
|
+
return t3(e4({}, this.converter, i3), this.attributes);
|
|
2227
|
+
} }, { attributes: { value: Object.freeze(n2) }, converter: { value: Object.freeze(i2) } });
|
|
2228
|
+
}
|
|
2229
|
+
return t3({ read: function(e5) {
|
|
2230
|
+
return '"' === e5[0] && (e5 = e5.slice(1, -1)), e5.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
|
2231
|
+
}, write: function(e5) {
|
|
2232
|
+
return encodeURIComponent(e5).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, decodeURIComponent);
|
|
2233
|
+
} }, { path: "/" });
|
|
2234
|
+
}();
|
|
2235
|
+
}, u(p = { exports: {} }, p.exports), p.exports), d = f, g = function() {
|
|
2236
|
+
function e3() {
|
|
2237
|
+
this.cache = {};
|
|
2238
|
+
}
|
|
2239
|
+
return e3.prototype.setItem = function(e4, t2) {
|
|
2240
|
+
this.cache[e4] = t2;
|
|
2241
|
+
}, e3.prototype.getItem = function(e4) {
|
|
2242
|
+
return this.cache[e4];
|
|
2243
|
+
}, e3.prototype.removeItem = function(e4) {
|
|
2244
|
+
this.cache[e4] = void 0;
|
|
2245
|
+
}, e3.prototype.getCookie = function(e4) {
|
|
2246
|
+
this.getItem(e4);
|
|
2247
|
+
}, e3.prototype.setCookie = function(e4, t2) {
|
|
2248
|
+
this.setItem(e4, t2);
|
|
2249
|
+
}, e3;
|
|
2250
|
+
}();
|
|
2251
|
+
var l, m = { getItem: function(e3) {
|
|
2252
|
+
try {
|
|
2253
|
+
var t2 = localStorage.getItem(e3), i2 = t2;
|
|
2254
|
+
try {
|
|
2255
|
+
t2 && "string" == typeof t2 && (i2 = JSON.parse(t2));
|
|
2256
|
+
} catch (e4) {
|
|
2257
|
+
}
|
|
2258
|
+
return i2 || {};
|
|
2259
|
+
} catch (e4) {
|
|
2260
|
+
}
|
|
2261
|
+
return {};
|
|
2262
|
+
}, setItem: function(e3, t2) {
|
|
2263
|
+
try {
|
|
2264
|
+
var i2 = "string" == typeof t2 ? t2 : JSON.stringify(t2);
|
|
2265
|
+
localStorage.setItem(e3, i2);
|
|
2266
|
+
} catch (e4) {
|
|
2267
|
+
}
|
|
2268
|
+
}, removeItem: function(e3) {
|
|
2269
|
+
try {
|
|
2270
|
+
localStorage.removeItem(e3);
|
|
2271
|
+
} catch (e4) {
|
|
2272
|
+
}
|
|
2273
|
+
}, getCookie: function(e3, t2) {
|
|
2274
|
+
try {
|
|
2275
|
+
return d.get(e3, { domain: t2 || document.domain });
|
|
2276
|
+
} catch (e4) {
|
|
2277
|
+
return "";
|
|
2278
|
+
}
|
|
2279
|
+
}, setCookie: function(e3, t2, i2, n2) {
|
|
2280
|
+
try {
|
|
2281
|
+
var o2 = n2 || document.domain, r2 = +/* @__PURE__ */ new Date() + i2;
|
|
2282
|
+
d.set(e3, t2, { expires: new Date(r2), path: "/", domain: o2 });
|
|
2283
|
+
} catch (e4) {
|
|
2284
|
+
}
|
|
2285
|
+
}, isSupportLS: function() {
|
|
2286
|
+
try {
|
|
2287
|
+
return localStorage.setItem("_ranger-test-key", "hi"), localStorage.getItem("_ranger-test-key"), localStorage.removeItem("_ranger-test-key"), true;
|
|
2288
|
+
} catch (e3) {
|
|
2289
|
+
return false;
|
|
2290
|
+
}
|
|
2291
|
+
}() }, _ = { getItem: function(e3) {
|
|
2292
|
+
try {
|
|
2293
|
+
var t2 = sessionStorage.getItem(e3), i2 = t2;
|
|
2294
|
+
try {
|
|
2295
|
+
t2 && "string" == typeof t2 && (i2 = JSON.parse(t2));
|
|
2296
|
+
} catch (e4) {
|
|
2297
|
+
}
|
|
2298
|
+
return i2 || {};
|
|
2299
|
+
} catch (e4) {
|
|
2300
|
+
}
|
|
2301
|
+
return {};
|
|
2302
|
+
}, setItem: function(e3, t2) {
|
|
2303
|
+
try {
|
|
2304
|
+
var i2 = "string" == typeof t2 ? t2 : JSON.stringify(t2);
|
|
2305
|
+
sessionStorage.setItem(e3, i2);
|
|
2306
|
+
} catch (e4) {
|
|
2307
|
+
}
|
|
2308
|
+
}, removeItem: function(e3) {
|
|
2309
|
+
try {
|
|
2310
|
+
sessionStorage.removeItem(e3);
|
|
2311
|
+
} catch (e4) {
|
|
2312
|
+
}
|
|
2313
|
+
}, getCookie: function(e3) {
|
|
2314
|
+
this.getItem(e3);
|
|
2315
|
+
}, setCookie: function(e3, t2) {
|
|
2316
|
+
this.setItem(e3, t2);
|
|
2317
|
+
}, isSupportSession: function() {
|
|
2318
|
+
try {
|
|
2319
|
+
return sessionStorage.setItem("_ranger-test-key", "hi"), sessionStorage.getItem("_ranger-test-key"), sessionStorage.removeItem("_ranger-test-key"), true;
|
|
2320
|
+
} catch (e3) {
|
|
2321
|
+
return false;
|
|
2322
|
+
}
|
|
2323
|
+
}() }, v = function() {
|
|
2324
|
+
function e3(e4, t2) {
|
|
2325
|
+
this._storage = t2 && "session" === t2 ? _ : !e4 && m.isSupportLS ? m : new g();
|
|
2326
|
+
}
|
|
2327
|
+
return e3.prototype.getItem = function(e4) {
|
|
2328
|
+
return this._storage.getItem(e4);
|
|
2329
|
+
}, e3.prototype.setItem = function(e4, t2) {
|
|
2330
|
+
this._storage.setItem(e4, t2);
|
|
2331
|
+
}, e3.prototype.getCookie = function(e4, t2) {
|
|
2332
|
+
return this._storage.getCookie(e4, t2);
|
|
2333
|
+
}, e3.prototype.setCookie = function(e4, t2, i2, n2) {
|
|
2334
|
+
this._storage.setCookie(e4, t2, i2, n2);
|
|
2335
|
+
}, e3.prototype.removeItem = function(e4) {
|
|
2336
|
+
this._storage.removeItem(e4);
|
|
2337
|
+
}, e3;
|
|
2338
|
+
}(), y = { cn: "1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az24z1mz1jz1az1cz18z1nz1nz1jz1mz1ez4az1az1mz1k", va: "1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k", sg: "1fz22z22z1nz21z4mz4bz4bz1kz1az21z4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k" }, w = void 0, b = (/* @__PURE__ */ new Date()).getTimezoneOffset(), k = parseInt("" + -b / 60, 10), x = 60 * b, O = function() {
|
|
2339
|
+
function t2(e3, t3) {
|
|
2340
|
+
this.is_first_time = true, this.initConfig = t3, this.collect = e3;
|
|
2341
|
+
var i2 = new h(t3.app_id).init(), n2 = "__tea_cache_first_" + t3.app_id;
|
|
2342
|
+
this.configKey = "__tea_cache_config_" + t3.app_id, this.sessionStorage = new v(false, "session"), this.localStorage = new v(false, "local");
|
|
2343
|
+
var o2 = this.localStorage.getItem(n2);
|
|
2344
|
+
o2 && 1 == o2 ? this.is_first_time = false : (this.is_first_time = true, this.localStorage.setItem(n2, "1")), this.envInfo = { user: { user_unique_id: w, user_type: w, user_id: w, user_is_auth: w, user_is_login: w, device_id: w, web_id: w, user_unique_id_type: w }, header: { app_id: w, app_name: w, app_install_id: w, install_id: w, app_package: w, app_channel: w, app_version: w, ab_version: w, os_name: i2.os_name, os_version: i2.os_version, device_model: i2.device_model, ab_client: w, traffic_type: w, client_ip: w, device_brand: w, os_api: w, access: w, language: i2.language, region: w, app_language: w, app_region: w, creative_id: w, ad_id: w, campaign_id: w, log_type: w, rnd: w, platform: i2.platform, sdk_version: "0.0.3-lite", sdk_lib: "js", province: w, city: w, timezone: k, tz_offset: x, tz_name: w, sim_region: w, carrier: w, resolution: i2.screen_width + "x" + i2.screen_height, browser: i2.browser, browser_version: i2.browser_version, referrer: i2.referrer, referrer_host: i2.referrer_host, width: i2.screen_width, height: i2.screen_height, screen_width: i2.screen_width, screen_height: i2.screen_height, utm_term: w, utm_content: w, utm_source: w, utm_medium: w, utm_campaign: w, custom: {}, wechat_unionid: w, wechat_openid: w } }, this.evtParams = {}, this.reportErrorCallback = function() {
|
|
2345
|
+
}, this.initDomain();
|
|
2346
|
+
}
|
|
2347
|
+
return t2.prototype.initDomain = function() {
|
|
2348
|
+
var e3 = this.initConfig.channel_domain;
|
|
2349
|
+
if (e3)
|
|
2350
|
+
this.domain = e3;
|
|
2351
|
+
else {
|
|
2352
|
+
var t3 = this.initConfig.channel;
|
|
2353
|
+
this.domain = a(y[t3]);
|
|
2354
|
+
}
|
|
2355
|
+
}, t2.prototype.setDomain = function(e3) {
|
|
2356
|
+
this.domain = e3;
|
|
2357
|
+
}, t2.prototype.getDomain = function() {
|
|
2358
|
+
return this.domain;
|
|
2359
|
+
}, t2.prototype.getUrl = function(e3) {
|
|
2360
|
+
var t3 = "";
|
|
2361
|
+
switch (e3) {
|
|
2362
|
+
case "event":
|
|
2363
|
+
t3 = this.initConfig.report_url || "/list";
|
|
2364
|
+
break;
|
|
2365
|
+
case "webid":
|
|
2366
|
+
t3 = "/webid";
|
|
2367
|
+
}
|
|
2368
|
+
return "" + this.getDomain() + t3;
|
|
2369
|
+
}, t2.prototype.set = function(t3) {
|
|
2370
|
+
var i2 = this;
|
|
2371
|
+
Object.keys(t3).forEach(function(n2) {
|
|
2372
|
+
"evtParams" === n2 ? i2.evtParams = e({}, i2.evtParams || {}, t3.evtParams || {}) : "_staging_flag" === n2 ? i2.evtParams = e({}, i2.evtParams || {}, { _staging_flag: t3._staging_flag }) : "reportErrorCallback" === n2 && "function" == typeof t3[n2] ? i2.reportErrorCallback = t3[n2] : Object.hasOwnProperty.call(i2.envInfo.user, n2) ? ["user_id", "web_id", "user_unique_id"].indexOf(n2) > -1 && (i2.envInfo.user[n2] = t3[n2] ? String(t3[n2]) : t3[n2]) : Object.hasOwnProperty.call(i2.envInfo.header, n2) ? i2.envInfo.header[n2] = t3[n2] : i2.envInfo.header.custom[n2] = t3[n2];
|
|
2373
|
+
});
|
|
2374
|
+
}, t2.prototype.get = function(e3) {
|
|
2375
|
+
try {
|
|
2376
|
+
return e3 ? "evtParams" === e3 ? this.evtParams : "reportErrorCallback" === e3 ? this[e3] : Object.hasOwnProperty.call(this.envInfo.user, e3) ? this.envInfo.user[e3] : Object.hasOwnProperty.call(this.envInfo.header, e3) ? this.envInfo.header[e3] : JSON.parse(JSON.stringify(this.envInfo[e3])) : JSON.parse(JSON.stringify(this.envInfo));
|
|
2377
|
+
} catch (e4) {
|
|
2378
|
+
console.log("get config stringify error ");
|
|
2379
|
+
}
|
|
2380
|
+
}, t2;
|
|
2381
|
+
}();
|
|
2382
|
+
!function(e3) {
|
|
2383
|
+
e3.Init = "init", e3.Config = "config", e3.Start = "start", e3.Ready = "ready", e3.TokenComplete = "token-complete", e3.TokenStorage = "token-storage", e3.TokenFetch = "token-fetch", e3.TokenError = "token-error", e3.ConfigUuid = "config-uuid", e3.TokenChange = "token-change", e3.TokenReset = "token-reset", e3.SessionReset = "session-reset", e3.SessionResetTime = "session-reset-time", e3.Event = "event", e3.Events = "events", e3.EventNow = "event-now", e3.CleanEvents = "clean-events", e3.BeconEvent = "becon-event";
|
|
2384
|
+
}(l || (l = {}));
|
|
2385
|
+
var I = l, S = 500, z = 5005;
|
|
2386
|
+
function M(e3, t2, i2, n2, o2, r2, s2, a2, c2) {
|
|
2387
|
+
try {
|
|
2388
|
+
var h2 = new XMLHttpRequest(), u2 = a2 || "POST";
|
|
2389
|
+
h2.open(u2, "" + e3, true), h2.setRequestHeader("Content-Type", "application/json; charset=utf-8"), i2 && (h2.timeout = i2, h2.ontimeout = function() {
|
|
2390
|
+
r2 && r2(t2, z);
|
|
2391
|
+
}), h2.onload = function() {
|
|
2392
|
+
if (o2) {
|
|
2393
|
+
var e4 = null;
|
|
2394
|
+
if (h2.responseText) {
|
|
2395
|
+
try {
|
|
2396
|
+
e4 = JSON.parse(h2.responseText);
|
|
2397
|
+
} catch (t3) {
|
|
2398
|
+
e4 = {};
|
|
2399
|
+
}
|
|
2400
|
+
o2(e4, t2);
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
}, h2.onerror = function() {
|
|
2404
|
+
h2.abort(), r2 && r2(t2, S);
|
|
2405
|
+
}, c2 ? h2.send(t2) : h2.send(JSON.stringify(t2));
|
|
2406
|
+
} catch (e4) {
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
var T = 4003, C = function() {
|
|
2410
|
+
function t2() {
|
|
2411
|
+
this.eventLimit = 50, this.eventCache = [], this.beconEventCache = [];
|
|
2412
|
+
}
|
|
2413
|
+
return t2.prototype.apply = function(e3, t3) {
|
|
2414
|
+
var i2 = this;
|
|
2415
|
+
this.collect = e3, this.config = t3, this.configManager = e3.configManager, this.cacheStorgae = new v(true), this.localStorage = new v(false), this.maxReport = t3.max_report || 20, this.reportTime = t3.reportTime || 30, this.timeout = t3.timeout || 1e5, this.reportUrl = this.configManager.getUrl("event"), this.eventKey = "__tea_cache_events_" + this.configManager.get("app_id"), this.beconKey = "__tea_cache_events_becon_" + this.configManager.get("app_id"), this.collect.on(I.Ready, function() {
|
|
2416
|
+
i2.reportAll(false);
|
|
2417
|
+
}), this.collect.on(I.Event, function(e4) {
|
|
2418
|
+
i2.event(e4);
|
|
2419
|
+
}), this.collect.on(I.BeconEvent, function(e4) {
|
|
2420
|
+
i2.beconEvent(e4);
|
|
2421
|
+
}), this.linster();
|
|
2422
|
+
}, t2.prototype.linster = function() {
|
|
2423
|
+
var e3 = this;
|
|
2424
|
+
window.addEventListener("unload", function() {
|
|
2425
|
+
e3.reportAll(true);
|
|
2426
|
+
}, false), function(e4) {
|
|
2427
|
+
navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) ? window.addEventListener("pagehide", e4, false) : window.addEventListener("beforeunload", e4, false);
|
|
2428
|
+
}(function() {
|
|
2429
|
+
e3.reportAll(true);
|
|
2430
|
+
}), document.addEventListener("visibilitychange", function() {
|
|
2431
|
+
"hidden" === document.visibilityState && e3.reportAll(true);
|
|
2432
|
+
}, false);
|
|
2433
|
+
}, t2.prototype.reportAll = function(e3) {
|
|
2434
|
+
this.report(e3), this.reportBecon();
|
|
2435
|
+
}, t2.prototype.event = function(e3) {
|
|
2436
|
+
var t3 = this;
|
|
2437
|
+
try {
|
|
2438
|
+
var n2 = i(e3, this.cacheStorgae.getItem(this.eventKey) || []);
|
|
2439
|
+
if (this.cacheStorgae.setItem(this.eventKey, n2), this.reportTimeout && clearTimeout(this.reportTimeout), n2.length >= this.maxReport)
|
|
2440
|
+
this.report(false);
|
|
2441
|
+
else {
|
|
2442
|
+
var o2 = this.reportTime;
|
|
2443
|
+
this.reportTimeout = setTimeout(function() {
|
|
2444
|
+
t3.report(false), t3.reportTimeout = null;
|
|
2445
|
+
}, o2);
|
|
2446
|
+
}
|
|
2447
|
+
} catch (e4) {
|
|
2448
|
+
}
|
|
2449
|
+
}, t2.prototype.beconEvent = function(e3) {
|
|
2450
|
+
var t3 = i(e3, this.cacheStorgae.getItem(this.beconKey) || []);
|
|
2451
|
+
this.cacheStorgae.setItem(this.beconKey, t3), this.collect.destroyInstance || this.collect.tokenManager.getReady() && this.collect.sdkReady && (this.cacheStorgae.removeItem(this.beconKey), this.send(this.split(this.merge(t3)), true));
|
|
2452
|
+
}, t2.prototype.reportBecon = function() {
|
|
2453
|
+
var e3 = this.cacheStorgae.getItem(this.beconKey) || [];
|
|
2454
|
+
e3 && e3.length && (this.cacheStorgae.removeItem(this.beconKey), this.send(this.split(this.merge(e3)), true));
|
|
2455
|
+
}, t2.prototype.report = function(e3) {
|
|
2456
|
+
if (!this.collect.destroyInstance && this.collect.tokenManager.getReady() && this.collect.sdkReady) {
|
|
2457
|
+
var t3 = this.cacheStorgae.getItem(this.eventKey) || [];
|
|
2458
|
+
t3.length && (this.cacheStorgae.removeItem(this.eventKey), this.sliceEvent(t3, e3));
|
|
2459
|
+
}
|
|
2460
|
+
}, t2.prototype.sliceEvent = function(e3, t3) {
|
|
2461
|
+
if (e3.length > this.eventLimit)
|
|
2462
|
+
for (var i2 = 0; i2 < e3.length; i2 += this.eventLimit) {
|
|
2463
|
+
var n2;
|
|
2464
|
+
n2 = e3.slice(i2, i2 + this.eventLimit);
|
|
2465
|
+
var o2 = this.split(this.merge(n2));
|
|
2466
|
+
this.send(o2, t3);
|
|
2467
|
+
}
|
|
2468
|
+
else {
|
|
2469
|
+
o2 = this.split(this.merge(e3));
|
|
2470
|
+
this.send(o2, t3);
|
|
2471
|
+
}
|
|
2472
|
+
}, t2.prototype.merge = function(t3) {
|
|
2473
|
+
var i2 = this, n2 = this.configManager.get(), o2 = n2.header, r2 = n2.user;
|
|
2474
|
+
o2.custom = JSON.stringify(o2.custom);
|
|
2475
|
+
var s2 = this.configManager.get("evtParams"), a2 = t3.map(function(t4) {
|
|
2476
|
+
try {
|
|
2477
|
+
return Object.keys(s2).length && (t4.params = e({}, s2, t4.params)), t4.session_id = i2.collect.sessionManager.getSessionId(), t4.params = JSON.stringify(t4.params), t4;
|
|
2478
|
+
} catch (e3) {
|
|
2479
|
+
return t4;
|
|
2480
|
+
}
|
|
2481
|
+
}), c2 = [];
|
|
2482
|
+
if (!Object.keys(r2).length)
|
|
2483
|
+
return console.warn("user info error,cant report"), c2;
|
|
2484
|
+
var h2 = JSON.parse(JSON.stringify({ events: a2, user: r2, header: o2 }));
|
|
2485
|
+
return h2.local_time = Math.floor(Date.now() / 1e3), h2.verbose = 1, c2.push(h2), c2;
|
|
2486
|
+
}, t2.prototype.split = function(e3) {
|
|
2487
|
+
return e3 = e3.map(function(e4) {
|
|
2488
|
+
var t3 = [];
|
|
2489
|
+
return t3.push(e4), t3;
|
|
2490
|
+
});
|
|
2491
|
+
}, t2.prototype.send = function(e3, t3) {
|
|
2492
|
+
var i2 = this;
|
|
2493
|
+
e3.length && e3.forEach(function(e4) {
|
|
2494
|
+
try {
|
|
2495
|
+
if (!e4.length)
|
|
2496
|
+
return;
|
|
2497
|
+
n2 = i2.reportUrl, o2 = e4, r2 = i2.timeout, s2 = function(e5, t4) {
|
|
2498
|
+
}, a2 = function(e5, t4) {
|
|
2499
|
+
i2.configManager.get("reportErrorCallback")(e5, t4);
|
|
2500
|
+
}, c2 = false, t3 && window.navigator && window.navigator.sendBeacon ? window.navigator.sendBeacon(n2, JSON.stringify(o2)) ? s2() : a2(n2, o2, T) : M(n2, o2, r2, 0, s2, a2, 0, "", c2);
|
|
2501
|
+
} catch (e5) {
|
|
2502
|
+
console.warn("something error, " + JSON.stringify(e5.stack));
|
|
2503
|
+
}
|
|
2504
|
+
var n2, o2, r2, s2, a2, c2;
|
|
2505
|
+
});
|
|
2506
|
+
}, t2;
|
|
2507
|
+
}(), E = function e2(t2) {
|
|
2508
|
+
return t2 ? (t2 ^ 16 * Math.random() >> t2 / 4).toString(10) : ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, e2);
|
|
2509
|
+
}, P = function() {
|
|
2510
|
+
return E().replace(/-/g, "").slice(0, 19);
|
|
2511
|
+
}, A = function() {
|
|
2512
|
+
function e3() {
|
|
2513
|
+
this.cacheToken = {};
|
|
2514
|
+
}
|
|
2515
|
+
return e3.prototype.apply = function(e4, t2) {
|
|
2516
|
+
var i2 = this;
|
|
2517
|
+
this.collect = e4, this.config = t2, this.configManager = this.collect.configManager, this.storage = new v(false), this.tokenKey = "__tea_cache_tokens_" + t2.app_id, this.collect.on(I.ConfigUuid, function(e5) {
|
|
2518
|
+
i2.setUuid(e5);
|
|
2519
|
+
}), this.checkStorage();
|
|
2520
|
+
}, e3.prototype.checkStorage = function() {
|
|
2521
|
+
this.cacheToken = this.storage.getItem(this.tokenKey) || {}, this.check();
|
|
2522
|
+
}, e3.prototype.check = function() {
|
|
2523
|
+
this.cacheToken && this.cacheToken.web_id ? this.complete(this.cacheToken) : this.remoteWebid();
|
|
2524
|
+
}, e3.prototype.remoteWebid = function() {
|
|
2525
|
+
var e4 = this, t2 = this.configManager.getUrl("webid"), i2 = { app_key: this.config.app_key, app_id: this.config.app_id, url: location.href, user_agent: window.navigator.userAgent, referer: document.referrer, user_unique_id: "" }, n2 = P();
|
|
2526
|
+
M(t2, i2, 3e5, 0, function(t3) {
|
|
2527
|
+
var i3;
|
|
2528
|
+
t3 && 0 === t3.e ? i3 = t3.web_id : (i3 = n2, e4.collect.configManager.set({ localWebId: n2 }), e4.collect.logger.warn("appid: " + e4.config.app_id + " get webid error, use local webid~")), e4.complete({ web_id: e4.configManager.get("web_id") || i3, user_unique_id: e4.configManager.get("user_unique_id") || i3 });
|
|
2529
|
+
}, function() {
|
|
2530
|
+
e4.complete({ web_id: e4.configManager.get("web_id") || n2, user_unique_id: e4.configManager.get("user_unique_id") || n2 }), e4.collect.configManager.set({ localWebId: n2 }), e4.collect.logger.warn("appid: " + e4.config.app_id + ", get webid error, use local webid~");
|
|
2531
|
+
});
|
|
2532
|
+
}, e3.prototype.complete = function(e4) {
|
|
2533
|
+
var t2 = e4.web_id, i2 = e4.user_unique_id;
|
|
2534
|
+
t2 || i2 ? (e4.timestamp = Date.now(), this.collect.configManager.set({ web_id: t2, user_unique_id: i2 }), this.setStorage(e4), this.tokenReady = true, this.collect.emit(I.TokenComplete)) : console.warn("token error");
|
|
2535
|
+
}, e3.prototype.setUuid = function(e4) {
|
|
2536
|
+
if (e4 && -1 === ["null", "undefined", "Null", "None"].indexOf(e4)) {
|
|
2537
|
+
var t2 = String(e4), i2 = this.configManager.get("user_unique_id"), n2 = this.cacheToken && this.cacheToken.user_unique_id;
|
|
2538
|
+
if (t2 === i2 && t2 === n2)
|
|
2539
|
+
return;
|
|
2540
|
+
this.configManager.set({ user_unique_id: t2 }), this.cacheToken || (this.cacheToken = {}), this.cacheToken.user_unique_id = t2, this.cacheToken.timestamp = Date.now(), this.setStorage(this.cacheToken);
|
|
2541
|
+
} else
|
|
2542
|
+
this.clearUuid();
|
|
2543
|
+
}, e3.prototype.clearUuid = function() {
|
|
2544
|
+
this.config.enable_ttwebid || this.configManager.get("web_id") && (this.configManager.set({ user_unique_id: this.configManager.get("web_id") }), this.cacheToken && this.cacheToken.web_id && (this.cacheToken.user_unique_id = this.cacheToken.web_id, this.cacheToken.timestamp = Date.now(), this.setStorage(this.cacheToken)), this.collect.emit(I.TokenReset));
|
|
2545
|
+
}, e3.prototype.setStorage = function(e4) {
|
|
2546
|
+
e4._type_ = "default", this.storage.setItem(this.tokenKey, e4), this.cacheToken = e4;
|
|
2547
|
+
}, e3.prototype.getReady = function() {
|
|
2548
|
+
return this.tokenReady;
|
|
2549
|
+
}, e3;
|
|
2550
|
+
}(), D = function() {
|
|
2551
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e3) {
|
|
2552
|
+
var t2 = 16 * Math.random() | 0;
|
|
2553
|
+
return ("x" === e3 ? t2 : 3 & t2 | 8).toString(16);
|
|
2554
|
+
});
|
|
2555
|
+
}, N = function() {
|
|
2556
|
+
function e3() {
|
|
2557
|
+
}
|
|
2558
|
+
return e3.prototype.apply = function(e4, t2) {
|
|
2559
|
+
var i2 = this;
|
|
2560
|
+
this.collect = e4, this.storage = new v(false, "session"), this.sessionKey = "__tea_session_id_" + t2.app_id, this.expireTime = t2.expireTime || 18e5, this.disableSession = t2.disable_session, this.disableSession || (this.setSessionId(), this.collect.on(I.SessionReset, function() {
|
|
2561
|
+
i2.resetSessionId();
|
|
2562
|
+
}), this.collect.on(I.SessionResetTime, function() {
|
|
2563
|
+
i2.updateSessionIdTime();
|
|
2564
|
+
}));
|
|
2565
|
+
}, e3.prototype.updateSessionIdTime = function() {
|
|
2566
|
+
var e4 = this.storage.getItem(this.sessionKey);
|
|
2567
|
+
if (e4 && e4.sessionId) {
|
|
2568
|
+
var t2 = e4.timestamp;
|
|
2569
|
+
Date.now() - t2 > this.expireTime ? e4 = { sessionId: D(), timestamp: Date.now() } : e4.timestamp = Date.now(), this.storage.setItem(this.sessionKey, e4), this.resetExpTime();
|
|
2570
|
+
}
|
|
2571
|
+
}, e3.prototype.setSessionId = function() {
|
|
2572
|
+
var e4 = this, t2 = this.storage.getItem(this.sessionKey);
|
|
2573
|
+
t2 && t2.sessionId ? t2.timestamp = Date.now() : t2 = { sessionId: D(), timestamp: Date.now() }, this.storage.setItem(this.sessionKey, t2), this.sessionExp = setInterval(function() {
|
|
2574
|
+
e4.checkEXp();
|
|
2575
|
+
}, this.expireTime);
|
|
2576
|
+
}, e3.prototype.getSessionId = function() {
|
|
2577
|
+
var e4 = this.storage.getItem(this.sessionKey);
|
|
2578
|
+
return this.disableSession ? "" : e4 && e4.sessionId ? e4.sessionId : "";
|
|
2579
|
+
}, e3.prototype.resetExpTime = function() {
|
|
2580
|
+
var e4 = this;
|
|
2581
|
+
this.sessionExp && (clearInterval(this.sessionExp), this.sessionExp = setInterval(function() {
|
|
2582
|
+
e4.checkEXp();
|
|
2583
|
+
}, this.expireTime));
|
|
2584
|
+
}, e3.prototype.resetSessionId = function() {
|
|
2585
|
+
var e4 = { sessionId: D(), timestamp: Date.now() };
|
|
2586
|
+
this.storage.setItem(this.sessionKey, e4);
|
|
2587
|
+
}, e3.prototype.checkEXp = function() {
|
|
2588
|
+
var e4 = this.storage.getItem(this.sessionKey);
|
|
2589
|
+
e4 && e4.sessionId && (Date.now() - e4.timestamp + 30 >= this.expireTime && (e4 = { sessionId: D(), timestamp: Date.now() }, this.storage.setItem(this.sessionKey, e4)));
|
|
2590
|
+
}, e3;
|
|
2591
|
+
}(), R = function() {
|
|
2592
|
+
function t2(e3) {
|
|
2593
|
+
this.disableAutoPageView = false, this.staging = false, this.sended = false, this.started = false, this.adapters = {}, this.sdkReady = false, this.name = e3, this.hook = new o(), this.Types = I, this.adapters.fetch = M, this.adapters.storage = v;
|
|
2594
|
+
}
|
|
2595
|
+
return t2.prototype.init = function(e3) {
|
|
2596
|
+
var t3, i2 = this;
|
|
2597
|
+
this.inited ? console.log("init can be call only one time") : e3 && r(e3) ? e3.app_id && ("number" == typeof (t3 = e3.app_id) && !isNaN(t3)) ? !e3.app_key || function(e4) {
|
|
2598
|
+
return "string" == typeof e4;
|
|
2599
|
+
}(e3.app_key) ? (e3.channel_domain || -1 !== ["cn", "sg", "va"].indexOf(e3.channel) || (console.warn("channel must be `cn`, `sg`,`va` !!!"), e3.channel = "cn"), this.inited = true, this.configManager = new O(this, e3), this.initConfig = e3, e3.disable_auto_pv && (this.disableAutoPageView = true), this.configManager.set({ app_id: e3.app_id }), this.eventManager = new C(), this.tokenManager = new A(), this.sessionManager = new N(), Promise.all([new Promise(function(e4) {
|
|
2600
|
+
i2.once(I.TokenComplete, function() {
|
|
2601
|
+
e4(true);
|
|
2602
|
+
});
|
|
2603
|
+
}), new Promise(function(e4) {
|
|
2604
|
+
i2.once(I.Start, function() {
|
|
2605
|
+
e4(true);
|
|
2606
|
+
});
|
|
2607
|
+
})]).then(function() {
|
|
2608
|
+
i2.sdkReady = true, i2.emit(I.Ready), console.info("appid: " + e3.app_id + ", userInfo:" + JSON.stringify(i2.configManager.get("user"))), console.info("appid: " + e3.app_id + ", sdk is ready, version is 0.0.3-lite, you can report now !!!"), i2.pageView();
|
|
2609
|
+
}), this.tokenManager.apply(this, e3), this.eventManager.apply(this, e3), this.sessionManager.apply(this, e3), this.emit(I.Init)) : console.warn("app_key param is error, must be string, please check!") : console.warn("app_id param is error, must be number, please check!") : console.warn("init params error,please check");
|
|
2610
|
+
}, t2.prototype.config = function(t3) {
|
|
2611
|
+
if (this.inited)
|
|
2612
|
+
if (t3 && r(t3)) {
|
|
2613
|
+
t3._staging_flag && 1 === t3._staging_flag && (this.staging = true), t3.disable_auto_pv && (this.disableAutoPageView = true, delete t3.disable_auto_pv);
|
|
2614
|
+
var i2 = e({}, t3);
|
|
2615
|
+
i2.user_unique_id;
|
|
2616
|
+
var n2 = function(e3, t4) {
|
|
2617
|
+
var i3 = {};
|
|
2618
|
+
for (var n3 in e3)
|
|
2619
|
+
Object.prototype.hasOwnProperty.call(e3, n3) && t4.indexOf(n3) < 0 && (i3[n3] = e3[n3]);
|
|
2620
|
+
if (null != e3 && "function" == typeof Object.getOwnPropertySymbols) {
|
|
2621
|
+
var o2 = 0;
|
|
2622
|
+
for (n3 = Object.getOwnPropertySymbols(e3); o2 < n3.length; o2++)
|
|
2623
|
+
t4.indexOf(n3[o2]) < 0 && Object.prototype.propertyIsEnumerable.call(e3, n3[o2]) && (i3[n3[o2]] = e3[n3[o2]]);
|
|
2624
|
+
}
|
|
2625
|
+
return i3;
|
|
2626
|
+
}(i2, ["user_unique_id"]);
|
|
2627
|
+
i2.hasOwnProperty("user_unique_id") && this.emit(I.ConfigUuid, i2.user_unique_id), this.configManager.set(n2);
|
|
2628
|
+
} else
|
|
2629
|
+
console.warn("config params is error, please check");
|
|
2630
|
+
else
|
|
2631
|
+
console.warn("config must be use after function init");
|
|
2632
|
+
}, t2.prototype.getConfig = function(e3) {
|
|
2633
|
+
return this.configManager.get(e3);
|
|
2634
|
+
}, t2.prototype.start = function() {
|
|
2635
|
+
this.inited && !this.sended && (this.sended = true, this.emit(I.Start));
|
|
2636
|
+
}, t2.prototype.event = function(e3, t3) {
|
|
2637
|
+
var i2 = this;
|
|
2638
|
+
try {
|
|
2639
|
+
var n2 = [];
|
|
2640
|
+
Array.isArray(e3) ? e3.forEach(function(e4) {
|
|
2641
|
+
n2.push(i2.processEvent(e4[0], e4[1] || {}));
|
|
2642
|
+
}) : n2.push(this.processEvent(e3, t3)), n2.length && (this.emit(I.Event, n2), this.emit(I.SessionResetTime));
|
|
2643
|
+
} catch (e4) {
|
|
2644
|
+
console.warn("something error, please check");
|
|
2645
|
+
}
|
|
2646
|
+
}, t2.prototype.beconEvent = function(e3, t3) {
|
|
2647
|
+
if (Array.isArray(e3))
|
|
2648
|
+
console.warn("beconEvent not support batch report, please check");
|
|
2649
|
+
else {
|
|
2650
|
+
var i2 = [];
|
|
2651
|
+
i2.push(this.processEvent(e3, t3 || {})), i2.length && (this.emit(I.BeconEvent, i2), this.emit(I.SessionResetTime));
|
|
2652
|
+
}
|
|
2653
|
+
}, t2.prototype.processEvent = function(e3, t3) {
|
|
2654
|
+
void 0 === t3 && (t3 = {});
|
|
2655
|
+
try {
|
|
2656
|
+
var i2 = e3;
|
|
2657
|
+
/^event\./.test(e3) && (i2 = e3.slice(6));
|
|
2658
|
+
var n2 = t3;
|
|
2659
|
+
"object" != typeof n2 && (n2 = {}), n2.event_index = s();
|
|
2660
|
+
var o2 = void 0;
|
|
2661
|
+
return n2.local_ms ? (o2 = n2.local_ms, delete n2.local_ms) : o2 = +/* @__PURE__ */ new Date(), { event: i2, params: n2, local_time_ms: o2 };
|
|
2662
|
+
} catch (i3) {
|
|
2663
|
+
return { event: e3, params: t3 };
|
|
2664
|
+
}
|
|
2665
|
+
}, t2.prototype.on = function(e3, t3) {
|
|
2666
|
+
this.hook.on(e3, t3);
|
|
2667
|
+
}, t2.prototype.once = function(e3, t3) {
|
|
2668
|
+
this.hook.once(e3, t3);
|
|
2669
|
+
}, t2.prototype.off = function(e3, t3) {
|
|
2670
|
+
this.hook.off(e3, t3);
|
|
2671
|
+
}, t2.prototype.emit = function(e3, t3, i2) {
|
|
2672
|
+
this.hook.emit(e3, t3, i2);
|
|
2673
|
+
}, t2.prototype.set = function(e3) {
|
|
2674
|
+
this.hook.set(e3);
|
|
2675
|
+
}, t2.prototype.pageView = function() {
|
|
2676
|
+
this.disableAutoPageView || this.predefinePageView();
|
|
2677
|
+
}, t2.prototype.predefinePageView = function(t3) {
|
|
2678
|
+
void 0 === t3 && (t3 = {});
|
|
2679
|
+
var i2 = { title: document.title || location.pathname, url: location.href, url_path: location.pathname, time: Date.now(), referrer: window.document.referrer, $is_first_time: "" + (this.configManager && this.configManager.is_first_time) }, n2 = e({}, i2, t3);
|
|
2680
|
+
this.event("predefine_pageview", n2);
|
|
2681
|
+
}, t2;
|
|
2682
|
+
}(), q = new R("default");
|
|
2683
|
+
const DEVICE_ID_KEY = "veplayer_live_device_id";
|
|
2684
|
+
const USER_ID_Key = "veplayer_live_user_id";
|
|
2685
|
+
const genRandomID2 = (length) => {
|
|
2686
|
+
return Math.floor(
|
|
2687
|
+
(Math.random() * 9 + 1) * Math.pow(10, length - 1)
|
|
2688
|
+
).toString();
|
|
2689
|
+
};
|
|
2690
|
+
const getDeviceID2 = () => {
|
|
2691
|
+
let deviceId = localStorage.getItem(DEVICE_ID_KEY);
|
|
2692
|
+
if (deviceId) {
|
|
2693
|
+
return deviceId;
|
|
2694
|
+
}
|
|
2695
|
+
deviceId = genRandomID2(11);
|
|
2696
|
+
localStorage.setItem(DEVICE_ID_KEY, deviceId);
|
|
2697
|
+
return deviceId;
|
|
2698
|
+
};
|
|
2699
|
+
const getUserId2 = () => {
|
|
2700
|
+
let userId = localStorage.getItem(USER_ID_Key);
|
|
2701
|
+
if (userId) {
|
|
2702
|
+
return userId;
|
|
2703
|
+
}
|
|
2704
|
+
userId = genRandomID2(12);
|
|
2705
|
+
localStorage.setItem(USER_ID_Key, userId);
|
|
2706
|
+
return userId;
|
|
2707
|
+
};
|
|
2708
|
+
const Plugin$2 = window["VePlayer"].Plugin;
|
|
2709
|
+
const CN_APPID = 468759;
|
|
2710
|
+
const CHANNEL = "cn";
|
|
2711
|
+
const CHANNEL_DOMAIN = "//mcs.volceapplog.com";
|
|
2712
|
+
class Logger extends Plugin$2 {
|
|
2713
|
+
constructor() {
|
|
2714
|
+
super(...arguments);
|
|
2715
|
+
__publicField(this, "_userId");
|
|
2716
|
+
__publicField(this, "_deviceId");
|
|
2717
|
+
__publicField(this, "_liveLogger");
|
|
2718
|
+
}
|
|
2719
|
+
static get pluginName() {
|
|
2720
|
+
return "logger";
|
|
2721
|
+
}
|
|
2722
|
+
static get defaultConfig() {
|
|
2723
|
+
return {
|
|
2724
|
+
appId: "",
|
|
2725
|
+
enable: true,
|
|
2726
|
+
showUserIdInErrorPanel: true
|
|
2727
|
+
};
|
|
2728
|
+
}
|
|
2729
|
+
afterCreate() {
|
|
2730
|
+
var _a, _b;
|
|
2731
|
+
if (!this.config.enable) {
|
|
2732
|
+
return;
|
|
2733
|
+
}
|
|
2734
|
+
if (!this.config.appId) {
|
|
2735
|
+
console.info("not found appId, please generate an appId");
|
|
2736
|
+
return;
|
|
2737
|
+
}
|
|
2738
|
+
this._userId = ((_a = this.config) == null ? void 0 : _a.userId) || getUserId2();
|
|
2739
|
+
this._deviceId = ((_b = this.config) == null ? void 0 : _b.deviceId) || getDeviceID2();
|
|
2740
|
+
this.open();
|
|
2741
|
+
}
|
|
2742
|
+
destroy() {
|
|
2743
|
+
this.close();
|
|
2744
|
+
}
|
|
2745
|
+
close() {
|
|
2746
|
+
var _a;
|
|
2747
|
+
(_a = this._liveLogger) == null ? void 0 : _a.destroy(false);
|
|
2748
|
+
this._liveLogger = void 0;
|
|
2749
|
+
}
|
|
2750
|
+
open() {
|
|
2751
|
+
if (this._liveLogger) {
|
|
2752
|
+
return;
|
|
2753
|
+
}
|
|
2754
|
+
this._start();
|
|
2755
|
+
if (this.config.showUserIdInErrorPanel && this.player.plugins.error) {
|
|
2756
|
+
this.player.plugins.error.config.extraTips = [
|
|
2757
|
+
{
|
|
2758
|
+
label: "userId",
|
|
2759
|
+
value: q == null ? void 0 : q.getConfig("user_unique_id")
|
|
2760
|
+
}
|
|
2761
|
+
];
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
_createTea() {
|
|
2765
|
+
q.init({
|
|
2766
|
+
app_id: CN_APPID,
|
|
2767
|
+
channel: CHANNEL,
|
|
2768
|
+
channel_domain: CHANNEL_DOMAIN
|
|
2769
|
+
});
|
|
2770
|
+
q.start();
|
|
2771
|
+
q.config({
|
|
2772
|
+
user_unique_id: this._userId,
|
|
2773
|
+
device_id: this._deviceId
|
|
2774
|
+
});
|
|
2775
|
+
}
|
|
2776
|
+
_start() {
|
|
2777
|
+
this._createTea();
|
|
2778
|
+
this._liveLogger = new LoggerControl({
|
|
2779
|
+
Tea: q,
|
|
2780
|
+
player: this.player,
|
|
2781
|
+
aid: this.config.appId,
|
|
2782
|
+
project_key: this.config.appId,
|
|
2783
|
+
app_name: this.config.appName || this.config.appId,
|
|
2784
|
+
user_id: this._userId,
|
|
2785
|
+
device_id: this._deviceId,
|
|
2786
|
+
ext: {
|
|
2787
|
+
veplayer_version: "2.0.0-rc.0",
|
|
2788
|
+
flv_version: "3.0.0-next.23",
|
|
2789
|
+
hls_version: "3.0.0-next.36-1",
|
|
2790
|
+
rts_version: "0.2.0-alpha.3"
|
|
2791
|
+
}
|
|
2792
|
+
});
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
function normalizeNumber(value, transform) {
|
|
2796
|
+
if (typeof value !== "number")
|
|
2797
|
+
return "-";
|
|
2798
|
+
return transform ? transform(value) : value.toString();
|
|
2799
|
+
}
|
|
2800
|
+
function getDefaultRow(data) {
|
|
2801
|
+
return {
|
|
2802
|
+
rows: [
|
|
2803
|
+
{
|
|
2804
|
+
key: "format",
|
|
2805
|
+
labelTextKey: "FORMAT",
|
|
2806
|
+
value: (data == null ? void 0 : data.format) ?? "-"
|
|
2807
|
+
},
|
|
2808
|
+
{
|
|
2809
|
+
key: "fps",
|
|
2810
|
+
labelTextKey: "FPS",
|
|
2811
|
+
value: normalizeNumber(data.fps, (value) => `${value} fps`)
|
|
2812
|
+
},
|
|
2813
|
+
{
|
|
2814
|
+
key: "bitrate",
|
|
2815
|
+
labelTextKey: "BITRATE",
|
|
2816
|
+
value: normalizeNumber(data.bitrate, (value) => `${value / 1e3} kbps`)
|
|
2817
|
+
},
|
|
2818
|
+
{
|
|
2819
|
+
key: "gop",
|
|
2820
|
+
labelTextKey: "GOP",
|
|
2821
|
+
value: normalizeNumber(data.gop, (value) => `${value} frames`)
|
|
2822
|
+
},
|
|
2823
|
+
{
|
|
2824
|
+
key: "resolution",
|
|
2825
|
+
labelTextKey: "RESOLUTION",
|
|
2826
|
+
value: `${normalizeNumber(data.height)} * ${normalizeNumber(
|
|
2827
|
+
data.height
|
|
2828
|
+
)}`
|
|
2829
|
+
},
|
|
2830
|
+
{
|
|
2831
|
+
key: "encodeType",
|
|
2832
|
+
labelTextKey: "ENCODE_TYPE",
|
|
2833
|
+
value: data.encodeType ?? "-"
|
|
2834
|
+
},
|
|
2835
|
+
{
|
|
2836
|
+
key: "bufferEnd",
|
|
2837
|
+
labelTextKey: "BUFFER_END",
|
|
2838
|
+
value: normalizeNumber(data.bufferEnd)
|
|
2839
|
+
},
|
|
2840
|
+
{
|
|
2841
|
+
key: "currentTime",
|
|
2842
|
+
labelTextKey: "CURRENT_TIME",
|
|
2843
|
+
value: normalizeNumber(
|
|
2844
|
+
data.currentTime,
|
|
2845
|
+
(value) => value.toFixed(6) + "s"
|
|
2846
|
+
)
|
|
2847
|
+
}
|
|
2848
|
+
]
|
|
2849
|
+
};
|
|
2850
|
+
}
|
|
2851
|
+
function getSoftDecodeRow(data) {
|
|
2852
|
+
return {
|
|
2853
|
+
titleTextKey: "DECODE_INFO",
|
|
2854
|
+
rows: [
|
|
2855
|
+
{
|
|
2856
|
+
key: "decodeEfficiency",
|
|
2857
|
+
labelTextKey: "DECODE_EFFICIENCY",
|
|
2858
|
+
value: normalizeNumber(data.decodeFps, (value) => value + "frames/s")
|
|
2859
|
+
},
|
|
2860
|
+
{
|
|
2861
|
+
key: "decodeCost",
|
|
2862
|
+
labelTextKey: "DECODE_COST",
|
|
2863
|
+
value: normalizeNumber(
|
|
2864
|
+
data.decodeFps,
|
|
2865
|
+
(value) => (value ? (1e3 / value).toFixed() : 0) + "ms"
|
|
2866
|
+
)
|
|
2867
|
+
}
|
|
2868
|
+
]
|
|
2869
|
+
};
|
|
2870
|
+
}
|
|
2871
|
+
var infoPanel = "";
|
|
2872
|
+
const util$1 = window["VePlayer"].util;
|
|
2873
|
+
const Plugin$1 = window["VePlayer"].Plugin;
|
|
2874
|
+
const XGUtil = window["VePlayer"].XGUtil;
|
|
2875
|
+
class InfoPanel extends Plugin$1 {
|
|
2876
|
+
constructor() {
|
|
2877
|
+
super(...arguments);
|
|
2878
|
+
__publicField(this, "_pollTimer");
|
|
2879
|
+
__publicField(this, "_visible");
|
|
2880
|
+
__publicField(this, "_playPlugin");
|
|
2881
|
+
}
|
|
2882
|
+
static get pluginName() {
|
|
2883
|
+
return "infoPanel";
|
|
2884
|
+
}
|
|
2885
|
+
static get defaultConfig() {
|
|
2886
|
+
return {
|
|
2887
|
+
visible: false,
|
|
2888
|
+
interval: 500
|
|
2889
|
+
};
|
|
2890
|
+
}
|
|
2891
|
+
get _streamType() {
|
|
2892
|
+
return util$1.getStreamType(this.player.config.url);
|
|
2893
|
+
}
|
|
2894
|
+
afterCreate() {
|
|
2895
|
+
this._playPlugin = this.player.plugins[this._streamType];
|
|
2896
|
+
this.player.on(Events.ERROR, () => this.close());
|
|
2897
|
+
if (this.config.visible) {
|
|
2898
|
+
this.player.once(Events.LOADED_DATA, () => this.open());
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2901
|
+
open() {
|
|
2902
|
+
if (this._visible) {
|
|
2903
|
+
return;
|
|
2904
|
+
}
|
|
2905
|
+
if (!["flv", "hls"].includes(this._streamType)) {
|
|
2906
|
+
console.warn("仅支持flv和hls格式的信息展示");
|
|
2907
|
+
return;
|
|
2908
|
+
}
|
|
2909
|
+
if (!this.player.plugins[this._streamType]) {
|
|
2910
|
+
console.warn(`不支持或未加载${this._streamType}插件`);
|
|
2911
|
+
return;
|
|
2912
|
+
}
|
|
2913
|
+
this.root.style.display = "block";
|
|
2914
|
+
this._tick();
|
|
2915
|
+
this._visible = true;
|
|
2916
|
+
}
|
|
2917
|
+
close() {
|
|
2918
|
+
if (!this._visible) {
|
|
2919
|
+
return;
|
|
2920
|
+
}
|
|
2921
|
+
clearTimeout(this._pollTimer);
|
|
2922
|
+
this.root.innerHTML = "";
|
|
2923
|
+
this.root.style.display = "none";
|
|
2924
|
+
this._visible = false;
|
|
2925
|
+
}
|
|
2926
|
+
destroy() {
|
|
2927
|
+
this.close();
|
|
2928
|
+
this.player.off(Events.LOADED_DATA, () => this.open());
|
|
2929
|
+
this.player.off(Events.ERROR, () => this.close());
|
|
2930
|
+
}
|
|
2931
|
+
render() {
|
|
2932
|
+
return `
|
|
2933
|
+
<xg-live-panel class="veplayer-live-panel">
|
|
2934
|
+
</xg-live-panel>
|
|
2935
|
+
`;
|
|
2936
|
+
}
|
|
2937
|
+
_tick() {
|
|
2938
|
+
clearTimeout(this._pollTimer);
|
|
2939
|
+
this._renderPanel();
|
|
2940
|
+
this._pollTimer = setTimeout(() => {
|
|
2941
|
+
this._tick();
|
|
2942
|
+
}, this.config.interval);
|
|
2943
|
+
}
|
|
2944
|
+
_getStats() {
|
|
2945
|
+
var _a;
|
|
2946
|
+
return (_a = this._playPlugin) == null ? void 0 : _a.getStats();
|
|
2947
|
+
}
|
|
2948
|
+
_getPanelData() {
|
|
2949
|
+
const stats = this._getStats() || {};
|
|
2950
|
+
const format = `${this._streamType}_live`;
|
|
2951
|
+
const isSoftDecode = this._playPlugin.softDecode;
|
|
2952
|
+
const groups = [
|
|
2953
|
+
getDefaultRow({
|
|
2954
|
+
...stats,
|
|
2955
|
+
format
|
|
2956
|
+
})
|
|
2957
|
+
];
|
|
2958
|
+
if (isSoftDecode) {
|
|
2959
|
+
groups.push(getSoftDecodeRow(stats));
|
|
2960
|
+
}
|
|
2961
|
+
return groups;
|
|
2962
|
+
}
|
|
2963
|
+
_renderPanel() {
|
|
2964
|
+
const panelData = this._getPanelData();
|
|
2965
|
+
const container = this.root;
|
|
2966
|
+
if (container) {
|
|
2967
|
+
container.innerHTML = "";
|
|
2968
|
+
panelData.forEach((group) => {
|
|
2969
|
+
this._renderGroup(container, group);
|
|
2970
|
+
});
|
|
2971
|
+
}
|
|
2972
|
+
}
|
|
2973
|
+
_renderGroup(container, { title, titleTextKey, rows }) {
|
|
2974
|
+
const i18nManager = this.player.config.i18nManager;
|
|
2975
|
+
if (title || titleTextKey) {
|
|
2976
|
+
const titleDom = this._genTitleDom(
|
|
2977
|
+
i18nManager.getText(titleTextKey) ?? title
|
|
2978
|
+
);
|
|
2979
|
+
container.appendChild(titleDom);
|
|
2980
|
+
}
|
|
2981
|
+
rows.forEach((row) => {
|
|
2982
|
+
const rowDom = this._genRowDom(row);
|
|
2983
|
+
container.appendChild(rowDom);
|
|
2984
|
+
});
|
|
2985
|
+
}
|
|
2986
|
+
_genTitleDom(item) {
|
|
2987
|
+
const rowDom = XGUtil.createDom(
|
|
2988
|
+
"xg-live-panel",
|
|
2989
|
+
"",
|
|
2990
|
+
void 0,
|
|
2991
|
+
"veplayer-live-panel-row"
|
|
2992
|
+
);
|
|
2993
|
+
const labelSpan = XGUtil.createDom(
|
|
2994
|
+
"xg-live-panel",
|
|
2995
|
+
item,
|
|
2996
|
+
void 0,
|
|
2997
|
+
"veplayer-live-panel-row-title"
|
|
2998
|
+
);
|
|
2999
|
+
rowDom.appendChild(labelSpan);
|
|
3000
|
+
return rowDom;
|
|
3001
|
+
}
|
|
3002
|
+
_genRowDom(item) {
|
|
3003
|
+
const i18nManager = this.player.config.i18nManager;
|
|
3004
|
+
const rowDom = XGUtil.createDom(
|
|
3005
|
+
"veplayer-live-panel-row",
|
|
3006
|
+
"",
|
|
3007
|
+
void 0,
|
|
3008
|
+
"veplayer-live-panel-row"
|
|
3009
|
+
);
|
|
3010
|
+
const labelSpan = XGUtil.createDom(
|
|
3011
|
+
"xg-live-panel",
|
|
3012
|
+
i18nManager.getText(item.labelTextKey),
|
|
3013
|
+
void 0,
|
|
3014
|
+
"veplayer-live-panel-row-label"
|
|
3015
|
+
);
|
|
3016
|
+
rowDom.appendChild(labelSpan);
|
|
3017
|
+
const valueSpan = XGUtil.createDom("xg-live-panel", item.value);
|
|
3018
|
+
rowDom.appendChild(valueSpan);
|
|
3019
|
+
return rowDom;
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
const BaseEN = window["VePlayer"].EN;
|
|
3023
|
+
const EN$1 = {
|
|
3024
|
+
...BaseEN,
|
|
3025
|
+
INVALID_PARAMETER: "The imported parameter is empty, please pass in necessary parameters such as the stream address",
|
|
3026
|
+
// info-panel
|
|
3027
|
+
FORMAT: "format",
|
|
3028
|
+
FPS: "fps",
|
|
3029
|
+
BITRATE: "bitrate",
|
|
3030
|
+
GOP: "gop",
|
|
3031
|
+
RESOLUTION: "resolution",
|
|
3032
|
+
ENCODE_TYPE: "encodeType",
|
|
3033
|
+
BUFFER_END: "bufferEnd",
|
|
3034
|
+
CURRENT_TIME: "currentTime",
|
|
3035
|
+
DECODE_EFFICIENCY: "efficiency",
|
|
3036
|
+
DECODE_COST: "cost",
|
|
3037
|
+
DECODE_INFO: "decodeInfo",
|
|
3038
|
+
REFRESH: "refresh"
|
|
3039
|
+
};
|
|
3040
|
+
const BaseZH_CN = window["VePlayer"].ZH_CN;
|
|
3041
|
+
const ZH_CN$1 = {
|
|
3042
|
+
...BaseZH_CN,
|
|
3043
|
+
INVALID_PARAMETER: "入参为空,请传入流地址等必要参数",
|
|
3044
|
+
// info-panel
|
|
3045
|
+
FORMAT: "格式",
|
|
3046
|
+
FPS: "帧率",
|
|
3047
|
+
BITRATE: "码率",
|
|
3048
|
+
GOP: "GOP",
|
|
3049
|
+
RESOLUTION: "视频分辨率",
|
|
3050
|
+
ENCODE_TYPE: "编码方式",
|
|
3051
|
+
BUFFER_END: "Buffer 水位",
|
|
3052
|
+
CURRENT_TIME: "播放进度",
|
|
3053
|
+
DECODE_EFFICIENCY: "解码效率",
|
|
3054
|
+
DECODE_COST: "解码消耗",
|
|
3055
|
+
DECODE_INFO: "软解信息",
|
|
3056
|
+
REFRESH: "刷新"
|
|
3057
|
+
};
|
|
3058
|
+
const DEFAULT_PLUGINS = window["VePlayer"].DEFAULT_PLUGINS;
|
|
3059
|
+
const VePlayerBase = window["VePlayer"].VePlayerBase;
|
|
3060
|
+
const VeI18n = window["VePlayer"].VeI18n;
|
|
3061
|
+
VeI18n.extend([
|
|
3062
|
+
{
|
|
3063
|
+
LANG: "zh-cn",
|
|
3064
|
+
TEXT: ZH_CN$1
|
|
3065
|
+
},
|
|
3066
|
+
{
|
|
3067
|
+
LANG: "en",
|
|
3068
|
+
TEXT: EN$1
|
|
3069
|
+
}
|
|
3070
|
+
]);
|
|
3071
|
+
const LIVE_DEFAULT_OPTIONS = {
|
|
3072
|
+
autoplay: { muted: true }
|
|
3073
|
+
};
|
|
3074
|
+
const LIVE_DEFAULT_PLUGINS = [...DEFAULT_PLUGINS, Refresh, Logger, InfoPanel];
|
|
3075
|
+
class VePlayerLive extends VePlayerBase {
|
|
3076
|
+
openLog() {
|
|
3077
|
+
var _a;
|
|
3078
|
+
(_a = this._player.plugins) == null ? void 0 : _a.logger.open();
|
|
3079
|
+
}
|
|
3080
|
+
closeLog() {
|
|
3081
|
+
var _a;
|
|
3082
|
+
(_a = this._player.plugins) == null ? void 0 : _a.logger.close();
|
|
3083
|
+
}
|
|
3084
|
+
openInfoPanel() {
|
|
3085
|
+
var _a;
|
|
3086
|
+
(_a = this._player.plugins) == null ? void 0 : _a.infopanel.open();
|
|
3087
|
+
}
|
|
3088
|
+
closeInfoPanel() {
|
|
3089
|
+
var _a;
|
|
3090
|
+
(_a = this._player.plugins) == null ? void 0 : _a.infopanel.close();
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
async function createLivePlayer(options) {
|
|
3094
|
+
if (!options || !options.url && !options.playlist) {
|
|
3095
|
+
throw create(ErrorCode.INVALID_PARAMETER, new VeI18n());
|
|
3096
|
+
}
|
|
3097
|
+
const i18n = new VeI18n({ lang: options == null ? void 0 : options.lang, i18n: options == null ? void 0 : options.i18n });
|
|
3098
|
+
const finalOptions = {
|
|
3099
|
+
...options,
|
|
3100
|
+
plugins: [...LIVE_DEFAULT_PLUGINS, ...options.plugins ?? []]
|
|
3101
|
+
};
|
|
3102
|
+
const player = await VePlayerBase.create(
|
|
3103
|
+
{
|
|
3104
|
+
...LIVE_DEFAULT_OPTIONS,
|
|
3105
|
+
...finalOptions,
|
|
3106
|
+
isLive: true,
|
|
3107
|
+
i18nManager: i18n,
|
|
3108
|
+
async preparePlugins(url) {
|
|
3109
|
+
return getTypeStrategy({ ...finalOptions, url });
|
|
3110
|
+
}
|
|
3111
|
+
},
|
|
3112
|
+
VePlayerLive
|
|
3113
|
+
);
|
|
3114
|
+
return player;
|
|
3115
|
+
}
|
|
3116
|
+
var live = /* @__PURE__ */ Object.freeze({
|
|
3117
|
+
__proto__: null,
|
|
3118
|
+
ErrorCode,
|
|
3119
|
+
Events
|
|
3120
|
+
});
|
|
3121
|
+
const setModuleSystem = window["VePlayer"].setModuleSystem;
|
|
3122
|
+
const Codec = window["VePlayer"].Codec;
|
|
3123
|
+
const DecodeType = window["VePlayer"].DecodeType;
|
|
3124
|
+
const Degradation = window["VePlayer"].Degradation;
|
|
3125
|
+
const POSITIONS = window["VePlayer"].POSITIONS;
|
|
3126
|
+
const register = window["VePlayer"].register;
|
|
3127
|
+
const EN = window["VePlayer"].EN;
|
|
3128
|
+
const ZH_CN = window["VePlayer"].ZH_CN;
|
|
3129
|
+
const Plugin = window["VePlayer"].Plugin;
|
|
3130
|
+
const Sniffer = window["VePlayer"].Sniffer;
|
|
3131
|
+
const DynamicModule = window["VePlayer"].DynamicModule;
|
|
3132
|
+
const util = window["VePlayer"].util;
|
|
3133
|
+
const load = window["VePlayer"].load;
|
|
3134
|
+
setModuleSystem("esm");
|
|
3135
|
+
const isMseSupported = util.isMseSupported;
|
|
3136
|
+
const isSoftDecodeSupported = util.isSoftDecodeSupported;
|
|
3137
|
+
export {
|
|
3138
|
+
Codec,
|
|
3139
|
+
DecodeType,
|
|
3140
|
+
Degradation,
|
|
3141
|
+
DynamicModule,
|
|
3142
|
+
EN,
|
|
3143
|
+
POSITIONS,
|
|
3144
|
+
Plugin,
|
|
3145
|
+
RTMCodec,
|
|
3146
|
+
Sniffer,
|
|
3147
|
+
ZH_CN,
|
|
3148
|
+
createLivePlayer,
|
|
3149
|
+
isMseSupported,
|
|
3150
|
+
isRTMSupportCodec,
|
|
3151
|
+
isRTMSupported,
|
|
3152
|
+
isSoftDecodeSupported,
|
|
3153
|
+
live,
|
|
3154
|
+
load,
|
|
3155
|
+
register,
|
|
3156
|
+
util
|
|
3157
|
+
};
|