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