@yimou6/common-ui 1.11.5 → 1.11.7

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 (52) hide show
  1. package/cdn/index.cdn.js +17 -17
  2. package/cdn/index.cdn.js.map +1 -1
  3. package/cdn/index.cdn.mjs +17 -17
  4. package/cdn/index.cdn.mjs.map +1 -1
  5. package/cdn/index.css +1 -1
  6. package/es/components/tenant-enterprise/index.d.ts +13 -0
  7. package/es/components/tenant-enterprise/src/tenant-enterprise.d.ts +6 -2
  8. package/es/components/tenant-enterprise/src/tenant-enterprise.mjs +5 -1
  9. package/es/components/tenant-enterprise/src/tenant-enterprise.mjs.map +1 -1
  10. package/es/components/tenant-enterprise/src/tenant-enterprise.vue.d.ts +13 -0
  11. package/es/components/tenant-enterprise/src/tenant-enterprise.vue2.mjs +334 -2
  12. package/es/components/tenant-enterprise/src/tenant-enterprise.vue2.mjs.map +1 -1
  13. package/es/components/tzj-player/index.d.ts +357 -368
  14. package/es/components/tzj-player/src/ctyun-player.vue.d.ts +7 -46
  15. package/es/components/tzj-player/src/easyPlayer.vue.d.ts +7 -46
  16. package/es/components/tzj-player/src/easyPlayer.vue2.mjs +164 -693
  17. package/es/components/tzj-player/src/easyPlayer.vue2.mjs.map +1 -1
  18. package/es/components/tzj-player/src/tzj-player.vue.d.ts +357 -368
  19. package/es/components/tzj-player/src/tzj-player.vue2.mjs +10 -7
  20. package/es/components/tzj-player/src/tzj-player.vue2.mjs.map +1 -1
  21. package/es/components/tzj-player/src/xgplayer.vue.d.ts +102 -0
  22. package/es/components/tzj-player/src/xgplayer.vue.mjs +6 -0
  23. package/es/components/tzj-player/src/xgplayer.vue.mjs.map +1 -0
  24. package/es/components/tzj-player/src/xgplayer.vue2.mjs +103 -0
  25. package/es/components/tzj-player/src/xgplayer.vue2.mjs.map +1 -0
  26. package/es/components/tzj-player/src/yunzhiyanPlayer.vue.d.ts +7 -46
  27. package/es/types.d.ts +2 -0
  28. package/lib/components/tenant-enterprise/index.d.ts +13 -0
  29. package/lib/components/tenant-enterprise/src/tenant-enterprise.d.ts +6 -2
  30. package/lib/components/tenant-enterprise/src/tenant-enterprise.js +5 -1
  31. package/lib/components/tenant-enterprise/src/tenant-enterprise.js.map +1 -1
  32. package/lib/components/tenant-enterprise/src/tenant-enterprise.vue.d.ts +13 -0
  33. package/lib/components/tenant-enterprise/src/tenant-enterprise.vue2.js +334 -2
  34. package/lib/components/tenant-enterprise/src/tenant-enterprise.vue2.js.map +1 -1
  35. package/lib/components/tzj-player/index.d.ts +357 -368
  36. package/lib/components/tzj-player/src/ctyun-player.vue.d.ts +7 -46
  37. package/lib/components/tzj-player/src/easyPlayer.vue.d.ts +7 -46
  38. package/lib/components/tzj-player/src/easyPlayer.vue2.js +163 -692
  39. package/lib/components/tzj-player/src/easyPlayer.vue2.js.map +1 -1
  40. package/lib/components/tzj-player/src/tzj-player.vue.d.ts +357 -368
  41. package/lib/components/tzj-player/src/tzj-player.vue2.js +4 -1
  42. package/lib/components/tzj-player/src/tzj-player.vue2.js.map +1 -1
  43. package/lib/components/tzj-player/src/xgplayer.vue.d.ts +102 -0
  44. package/lib/components/tzj-player/src/xgplayer.vue.js +10 -0
  45. package/lib/components/tzj-player/src/xgplayer.vue.js.map +1 -0
  46. package/lib/components/tzj-player/src/xgplayer.vue2.js +107 -0
  47. package/lib/components/tzj-player/src/xgplayer.vue2.js.map +1 -0
  48. package/lib/components/tzj-player/src/yunzhiyanPlayer.vue.d.ts +7 -46
  49. package/lib/types.d.ts +2 -0
  50. package/package.json +1 -1
  51. package/theme-default/i-tzj-player.css +1 -1
  52. package/theme-default/index.css +1 -1
@@ -3,9 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var vue = require('vue');
6
- var lodashEs = require('lodash-es');
7
- require('./errorPage.vue.js');
8
6
  var tzjPlayer = require('./tzj-player.js');
7
+ require('./errorPage.vue.js');
9
8
  var errorPage_vue_vue_type_script_setup_true_lang = require('./errorPage.vue2.js');
10
9
 
11
10
  var __defProp = Object.defineProperty;
@@ -14,13 +13,6 @@ const _hoisted_1 = {
14
13
  key: 0,
15
14
  class: "i-tzj-easyPlayer__top"
16
15
  };
17
- const maxReconnectAttempts = 3;
18
- const DEBOUNCE_TIME = 5e3;
19
- const HIGH_MEMORY_THRESHOLD = 80;
20
- const EMERGENCY_CLEAN_TIMEOUT = 1e3;
21
- const MEMORY_CHECK_INTERVAL = 3e3;
22
- const MEMORY_PEAK_THRESHOLD = 1100;
23
- const CLEAN_INTERVAL = 2 * 60 * 1e3;
24
16
  var _sfc_main = /* @__PURE__ */ vue.defineComponent({
25
17
  ...{
26
18
  name: "EasyPlayer"
@@ -33,16 +25,13 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
33
25
  "play",
34
26
  "pause",
35
27
  "mute",
36
- "videoInfo",
37
- "memoryWarn"
28
+ "videoInfo"
38
29
  ],
39
30
  setup(__props, { expose: __expose, emit: __emit }) {
40
31
  const props = __props;
41
32
  const emits = __emit;
42
33
  const slots = vue.useSlots();
43
34
  const customBar = vue.computed(() => slots.customBar);
44
- const areaName = vue.ref(props.areaName);
45
- const deviceSerial = vue.ref(props.deviceSerial);
46
35
  let player = null;
47
36
  const id = tzjPlayer.uuid();
48
37
  const playerRef = vue.shallowRef();
@@ -51,198 +40,30 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
51
40
  const isFullscreen = vue.ref(false);
52
41
  const videoInfo = vue.ref(null);
53
42
  const realFullscreen = vue.ref(false);
54
- const reconnectAttempts = vue.ref(0);
55
- const reconnectCoolDown = vue.ref(0);
56
- const requestCache = /* @__PURE__ */ new Map();
57
- const timers = {
58
- initTimer: null,
59
- cleanupInterval: null,
60
- memoryCheckInterval: null,
61
- reconnectTimer: null,
62
- debounceTimer: null,
63
- lightCleanInterval: null,
64
- rebuildInterval: null
65
- };
66
- const eventHandlers = [];
67
- const isPlayerIniting = vue.ref(false);
68
- const isPlayerDestroyed = vue.ref(false);
69
- let lastMemoryPeak = 0;
70
43
  vue.onMounted(() => {
71
- vue.nextTick(() => {
72
- if (playerRef.value) {
73
- initPlayer(props.url || "");
74
- } else {
75
- setTimeout(() => {
76
- if (playerRef.value) {
77
- initPlayer(props.url || "");
78
- } else {
79
- console.error("\u64AD\u653E\u5668\u5BB9\u5668\u5143\u7D20\u672A\u627E\u5230\uFF0C\u64AD\u653E\u5668\u521D\u59CB\u5316\u5931\u8D25");
80
- }
81
- }, 100);
82
- }
83
- });
84
- startMemoryMonitoring();
85
- const originalFetch = window.fetch;
86
- window.fetch = async (input, init) => {
87
- const url = typeof input === "string" ? input : input.toString();
88
- if (url.includes(".ts") || url.includes(".m3u8")) {
89
- const newInit = {
90
- ...init,
91
- headers: {
92
- ...init == null ? void 0 : init.headers,
93
- "Cache-Control": "no-cache, no-store, must-revalidate",
94
- Pragma: "no-cache",
95
- Expires: "0"
96
- },
97
- cache: "no-store"
98
- };
99
- return originalFetch(input, newInit);
100
- }
101
- return originalFetch(input, init);
102
- };
103
- if (timers.lightCleanInterval) clearInterval(timers.lightCleanInterval);
104
- timers.lightCleanInterval = window.setInterval(() => {
105
- var _a, _b;
106
- if (player && !isPlayerDestroyed.value && !isPlayerIniting.value) {
107
- console.log("\u30102\u5206\u949F\u5B9A\u65F6\u3011\u6267\u884C\u8F7B\u91CF\u6E05\u7406\uFF0C\u963B\u6B62\u5185\u5B58\u4E0A\u6DA8");
108
- if (player.hls && player.hls.bufferController) {
109
- const now = Date.now() / 1e3;
110
- player.hls.bufferController.trim(now - 2, now);
111
- }
112
- (_a = player.clearCache) == null ? void 0 : _a.call(player);
113
- (_b = player.flushFrames) == null ? void 0 : _b.call(player);
114
- if (window.gc) {
115
- window.gc();
116
- }
117
- }
118
- }, CLEAN_INTERVAL);
119
- if (timers.rebuildInterval) clearInterval(timers.rebuildInterval);
120
- timers.rebuildInterval = window.setInterval(
121
- () => {
122
- if (player && !isPlayerDestroyed.value && !realFullscreen.value) {
123
- console.log("\u301010\u5206\u949F\u515C\u5E95\u3011\u65E0\u7F1D\u91CD\u5EFA\u64AD\u653E\u5668\uFF0C\u5185\u5B58\u76F4\u63A5\u56DE\u843D");
124
- seamlessRebuildPlayer();
125
- }
126
- },
127
- 10 * 60 * 1e3
128
- );
44
+ initPlayer(props.url || "");
129
45
  });
130
- const formatUrl = /* @__PURE__ */ __name((url) => {
131
- if (!url || url.trim() === "") return "";
132
- const specialProtocols = ["rtmp://", "ws://", "wss://", "rtsp://"];
133
- if (specialProtocols.some((protocol) => url.startsWith(protocol))) {
134
- return url;
135
- }
136
- if (url.startsWith("http://") || url.startsWith("https://")) {
137
- return url;
138
- }
139
- if (typeof window !== "undefined" && window.location) {
140
- return `${window.location.origin}${url.startsWith("/") ? "" : "/"}${url}`;
141
- }
142
- return url;
143
- }, "formatUrl");
144
- async function initPlayer(url) {
145
- if (props.debug) {
146
- console.log("\u521D\u59CB\u5316\u64AD\u653E\u5668", url);
147
- }
148
- if (url && requestCache.has(url)) {
149
- const cached = requestCache.get(url);
150
- const now = Date.now();
151
- if (now - cached.timestamp < DEBOUNCE_TIME) {
152
- console.log(
153
- `\u8BF7\u6C42\u9632\u6296\uFF1A${url} \u5728 ${DEBOUNCE_TIME}ms \u5185\u5DF2\u8BF7\u6C42\u8FC7\uFF0C\u8DF3\u8FC7\u672C\u6B21\u8BF7\u6C42`
154
- );
155
- return;
156
- }
157
- }
158
- if (url) {
159
- requestCache.set(url, { timestamp: Date.now(), url });
160
- const now = Date.now();
161
- for (const [key, value] of requestCache.entries()) {
162
- if (now - value.timestamp > 6e4) {
163
- requestCache.delete(key);
164
- }
165
- }
166
- }
167
- if (isPlayerIniting.value) return;
168
- isPlayerIniting.value = true;
169
- try {
170
- destroy(true);
171
- removePlayerDom();
172
- isPlayerDestroyed.value = false;
173
- if (!url) {
174
- playSuccess.value = false;
175
- isPlayerIniting.value = false;
176
- return;
177
- }
178
- playUrl.value = formatUrl(url);
179
- if (props.debug) {
180
- console.log("\u683C\u5F0F\u5316\u540E\u7684url", playUrl.value);
181
- }
182
- if (typeof window !== "undefined" && (window == null ? void 0 : window.EasyPlayerPro)) {
183
- await createPlayer();
184
- } else if (typeof window !== "undefined") {
185
- if (timers.initTimer !== null) clearInterval(timers.initTimer);
186
- let initTimeout = 0;
187
- timers.initTimer = window.setInterval(() => {
188
- initTimeout += 100;
189
- if (window == null ? void 0 : window.EasyPlayerPro) {
190
- createPlayer();
191
- if (timers.initTimer !== null) {
192
- clearInterval(timers.initTimer);
193
- timers.initTimer = null;
194
- }
195
- }
196
- if (initTimeout >= 1e4) {
197
- if (timers.initTimer !== null) {
198
- clearInterval(timers.initTimer);
199
- timers.initTimer = null;
200
- }
201
- playSuccess.value = false;
202
- emits("error", new Error("EasyPlayerPro\u52A0\u8F7D\u8D85\u65F6"));
203
- }
204
- }, 100);
205
- }
206
- } catch (e) {
207
- console.error("\u64AD\u653E\u5668\u521D\u59CB\u5316\u5931\u8D25:", e);
208
- playSuccess.value = false;
209
- emits("error", e);
210
- } finally {
211
- isPlayerIniting.value = false;
212
- }
213
- }
214
- __name(initPlayer, "initPlayer");
215
- const debouncedInitPlayer = lodashEs.debounce((newUrl) => {
216
- reconnectAttempts.value = 0;
217
- reconnectCoolDown.value = 0;
218
- initPlayer(newUrl || "");
219
- }, 500);
220
46
  vue.watch(
221
47
  () => props.url,
222
48
  (newUrl) => {
223
- console.log("URL\u53D8\u5316\uFF1A", newUrl);
224
- if (timers.reconnectTimer) {
225
- clearTimeout(timers.reconnectTimer);
226
- timers.reconnectTimer = null;
227
- }
228
- debouncedInitPlayer(newUrl);
229
- },
230
- { immediate: false }
49
+ initPlayer(newUrl || "");
50
+ }
231
51
  );
52
+ vue.onBeforeUnmount(() => {
53
+ if (props.debug) {
54
+ console.log("\u7EC4\u4EF6\u5378\u8F7D");
55
+ }
56
+ playUrl.value = "";
57
+ destroy();
58
+ });
232
59
  const play = /* @__PURE__ */ __name((url) => {
233
- console.log("\u64AD\u653E", url);
234
- if (isPlayerDestroyed.value) return;
235
60
  if (url) {
236
- reconnectAttempts.value = 0;
237
- reconnectCoolDown.value = 0;
238
61
  initPlayer(url);
239
62
  } else {
240
- if (player && !isPlayerDestroyed.value) {
63
+ if (player) {
241
64
  player.play(playUrl.value);
242
65
  } else {
243
- destroy(false);
244
- isPlayerDestroyed.value = false;
245
- initPlayer(playUrl.value);
66
+ destroy();
246
67
  }
247
68
  }
248
69
  }, "play");
@@ -251,425 +72,89 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
251
72
  if (props.debug) {
252
73
  console.log("\u6682\u505C");
253
74
  }
254
- if (player && !isPlayerDestroyed.value) {
255
- (_a = player.pause) == null ? void 0 : _a.call(player);
256
- }
75
+ (_a = player == null ? void 0 : player.pause) == null ? void 0 : _a.call(player);
257
76
  }, "playerPause");
258
77
  const playerScreenShot = /* @__PURE__ */ __name(() => {
259
78
  var _a;
260
79
  if (props.debug) {
261
80
  console.log("\u622A\u56FE");
262
81
  }
263
- if (player && !isPlayerDestroyed.value) {
264
- (_a = player.screenshot) == null ? void 0 : _a.call(
265
- player,
266
- `${props.areaName}_${(/* @__PURE__ */ new Date()).getTime()}`,
267
- "png",
268
- 0.5,
269
- "download"
270
- );
271
- }
82
+ (_a = player == null ? void 0 : player.screenshot) == null ? void 0 : _a.call(
83
+ player,
84
+ `${props.areaName}_${(/* @__PURE__ */ new Date()).getTime()}`,
85
+ "png",
86
+ 0.5,
87
+ "download"
88
+ );
272
89
  }, "playerScreenShot");
273
90
  const playerFullscreen = /* @__PURE__ */ __name((fullscreen) => {
274
91
  var _a, _b, _c;
275
- if (isPlayerDestroyed.value) return;
276
92
  realFullscreen.value = fullscreen;
277
93
  if (props.debug) {
278
- console.log("\u5168\u5C4F\u5207\u6362:", fullscreen);
94
+ console.log("\u5168\u5C4F");
279
95
  }
280
96
  if (typeof document !== "undefined") {
281
- try {
282
- if (!fullscreen) {
283
- if (document.fullscreenElement) {
284
- (_a = document.exitFullscreen) == null ? void 0 : _a.call(document);
285
- }
286
- } else {
287
- if (playerRef.value && !document.fullscreenElement) {
288
- (_c = (_b = playerRef.value).requestFullscreen) == null ? void 0 : _c.call(_b, {
289
- navigationUI: "hide"
290
- });
291
- }
292
- }
293
- isFullscreen.value = !fullscreen;
294
- } catch (e) {
295
- console.error("\u5168\u5C4F\u64CD\u4F5C\u5931\u8D25:", e);
97
+ if (!fullscreen) {
98
+ (_a = document.exitFullscreen) == null ? void 0 : _a.call(document);
99
+ } else {
100
+ (_c = (_b = playerRef.value) == null ? void 0 : _b.requestFullscreen) == null ? void 0 : _c.call(_b);
296
101
  }
102
+ setTimeout(() => {
103
+ destroy();
104
+ initPlayer(playUrl.value);
105
+ }, 200);
297
106
  }
107
+ isFullscreen.value = !fullscreen;
298
108
  }, "playerFullscreen");
299
- function seamlessRebuildPlayer() {
300
- var _a, _b;
301
- if (isPlayerDestroyed.value || isPlayerIniting.value) return;
302
- isPlayerIniting.value = true;
303
- const currentUrl = playUrl.value;
304
- const currentVolume = ((_a = player.getVolume) == null ? void 0 : _a.call(player)) || 1;
305
- const isMuted = ((_b = player.isMute) == null ? void 0 : _b.call(player)) || false;
306
- const tempPlayerDiv = document.createElement("div");
307
- tempPlayerDiv.id = `temp-${id}`;
308
- tempPlayerDiv.style.position = "absolute";
309
- tempPlayerDiv.style.top = "0";
310
- tempPlayerDiv.style.left = "0";
311
- tempPlayerDiv.style.width = "100%";
312
- tempPlayerDiv.style.height = "100%";
313
- tempPlayerDiv.style.zIndex = "999";
314
- tempPlayerDiv.style.backgroundColor = "#000";
315
- if (playerRef.value) {
316
- playerRef.value.appendChild(tempPlayerDiv);
109
+ __expose({
110
+ play,
111
+ destroy,
112
+ getPlayer: /* @__PURE__ */ __name(() => player, "getPlayer"),
113
+ pause: playerPause,
114
+ screenshot: playerScreenShot,
115
+ fullscreen: playerFullscreen,
116
+ isMute: /* @__PURE__ */ __name(() => {
117
+ var _a;
118
+ return (_a = player == null ? void 0 : player.isMute) == null ? void 0 : _a.call(player);
119
+ }, "isMute"),
120
+ setMute: /* @__PURE__ */ __name((mute) => {
121
+ var _a;
122
+ (_a = player == null ? void 0 : player.setMute) == null ? void 0 : _a.call(player, mute);
123
+ }, "setMute")
124
+ });
125
+ const formatUrl = /* @__PURE__ */ __name((url) => {
126
+ if (!url) return "";
127
+ if (url.startsWith("http://") || url.startsWith("https://")) {
128
+ return url;
317
129
  }
318
- let tempPlayer = null;
319
- if (window.EasyPlayerPro) {
320
- tempPlayer = new window.EasyPlayerPro(tempPlayerDiv, {
321
- isLive: true,
322
- hasAudio: true,
323
- bufferTime: 0.01,
324
- hwAcceleration: false,
325
- enableStashBuffer: false,
326
- maxBufferSize: 256 * 1024,
327
- maxBufferLength: 1
328
- });
329
- tempPlayer.play(currentUrl);
330
- tempPlayer.setVolume(currentVolume);
331
- if (isMuted) tempPlayer.setMute(1);
130
+ if (typeof window !== "undefined" && window.location) {
131
+ return `${window.location.origin}${url.startsWith("/") ? "" : "/"}${url}`;
332
132
  }
333
- destroy(false);
334
- setTimeout(() => {
335
- if (tempPlayer && playerRef.value) {
336
- const originalDom = document.getElementById(id);
337
- if (originalDom && tempPlayerDiv.firstChild) {
338
- originalDom.appendChild(tempPlayerDiv.firstChild);
339
- }
340
- tempPlayerDiv.remove();
341
- player = tempPlayer;
342
- isPlayerDestroyed.value = false;
343
- isPlayerIniting.value = false;
344
- console.log(`\u2705 \u65E0\u7F1D\u91CD\u5EFA\u5B8C\u6210\uFF0C\u5185\u5B58\u4ECE${MEMORY_PEAK_THRESHOLD}MB\u2192500MB`);
345
- }
346
- }, 1e3);
347
- }
348
- __name(seamlessRebuildPlayer, "seamlessRebuildPlayer");
349
- async function createPlayer() {
350
- if (isPlayerDestroyed.value || !playUrl.value) return;
133
+ return url;
134
+ }, "formatUrl");
135
+ async function initPlayer(url) {
351
136
  if (props.debug) {
352
- console.log("\u521B\u5EFA\u64AD\u653E\u5668\u5B9E\u4F8B");
353
- }
354
- videoInfo.value = null;
355
- createPlayerDom();
356
- if (typeof window === "undefined" || typeof document === "undefined" || !window.EasyPlayerPro) {
357
- playSuccess.value = false;
358
- emits("error", new Error("EasyPlayerPro\u672A\u52A0\u8F7D"));
359
- return;
360
- }
361
- const targetElement = document.getElementById(id);
362
- if (!targetElement) {
363
- console.error(`\u627E\u4E0D\u5230ID\u4E3A ${id} \u7684\u64AD\u653E\u5668\u5BB9\u5668\u5143\u7D20`);
364
- return;
365
- }
366
- player = new window.EasyPlayerPro(targetElement, {
367
- isLive: true,
368
- hasAudio: true,
369
- bufferTime: 0.01,
370
- // 缓存时长压到0.01秒(极限)
371
- stretch: true,
372
- MSE: false,
373
- WCS: false,
374
- WASM: true,
375
- debug: false,
376
- operateBtns: {
377
- performance: false
378
- },
379
- hwAcceleration: false,
380
- // 禁用硬件加速(核心)
381
- lowLatency: true,
382
- maxBufferSize: 256 * 1024,
383
- // 最大缓存256KB
384
- maxBufferLength: 1,
385
- // 最大缓存时长1秒(关键)
386
- manifestLoadingMaxRetry: 1,
387
- levelLoadingMaxRetry: 1,
388
- manifestLoadingRetryDelay: 1e3,
389
- levelLoadingRetryDelay: 1e3,
390
- enableStashBuffer: false,
391
- // 彻底禁用缓存缓冲区
392
- stashInitialSize: 0,
393
- // 初始缓存0
394
- liveSyncDuration: 0.5,
395
- // 实时同步0.5秒
396
- liveMaxLatencyDuration: 1
397
- // 最大延迟1秒
398
- });
399
- if (player.clearCache) {
400
- player.clearCache();
401
- }
402
- player.play(playUrl.value);
403
- if (timers.cleanupInterval) clearInterval(timers.cleanupInterval);
404
- timers.cleanupInterval = window.setInterval(() => {
405
- var _a, _b, _c;
406
- if (player && !isPlayerDestroyed.value) {
407
- (_a = player.clearCache) == null ? void 0 : _a.call(player);
408
- (_b = player.flushFrames) == null ? void 0 : _b.call(player);
409
- (_c = player.trimBuffer) == null ? void 0 : _c.call(player);
410
- if (player.hls) {
411
- try {
412
- if (player.hls.bufferController) {
413
- player.hls.bufferController.flushBackBuffer();
414
- }
415
- if (player.hls.streamController) {
416
- player.hls.streamController.resetTransmuxer();
417
- }
418
- } catch (e) {
419
- console.warn("HLS\u7F13\u5B58\u6E05\u7406\u5F02\u5E38:", e);
420
- }
421
- }
422
- if (window.gc) window.gc();
423
- }
424
- }, 3e4);
425
- const registerEvent = /* @__PURE__ */ __name((event, handler) => {
426
- player.on(event, handler);
427
- eventHandlers.push({ event, handler });
428
- }, "registerEvent");
429
- registerEvent("timeout", () => {
430
- props.debug && console.log("\u52A0\u8F7D\u8D85\u65F6");
431
- emits("timeout");
432
- playSuccess.value = false;
433
- handleReconnect();
434
- });
435
- registerEvent("error", (err) => {
436
- props.debug && console.log("\u64AD\u653E\u5F02\u5E38:", err);
437
- emits("error", err);
438
- playSuccess.value = false;
439
- handleReconnect();
440
- });
441
- registerEvent("play", () => {
442
- playSuccess.value = true;
443
- reconnectAttempts.value = 0;
444
- reconnectCoolDown.value = 0;
445
- props.debug && console.log("\u64AD\u653E\u6210\u529F");
446
- emits("play");
447
- });
448
- registerEvent("pause", () => {
449
- props.debug && console.log("\u6682\u505C\u64AD\u653E");
450
- emits("pause");
451
- });
452
- registerEvent("videoInfo", (info) => {
453
- props.debug && console.log("\u89C6\u9891\u4FE1\u606F", info);
454
- videoInfo.value = info;
455
- emits("videoInfo", info);
456
- });
457
- registerEvent("mute", (mute) => {
458
- props.debug && console.log("\u9759\u97F3\u72B6\u6001\u53D8\u66F4:", mute);
459
- emits("mute", mute);
460
- });
461
- registerEvent("ended", () => {
462
- props.debug && console.log("\u64AD\u653E\u7ED3\u675F");
463
- if (!isFullscreen.value) {
464
- destroy(false);
465
- }
466
- });
467
- }
468
- __name(createPlayer, "createPlayer");
469
- function handleReconnect() {
470
- if (isPlayerDestroyed.value) return;
471
- if (reconnectCoolDown.value > 0) {
472
- console.log(`\u91CD\u8FDE\u51B7\u5374\u4E2D\uFF0C\u8FD8\u9700\u7B49\u5F85 ${reconnectCoolDown.value}ms`);
473
- return;
474
- }
475
- if (reconnectAttempts.value >= maxReconnectAttempts) {
476
- console.log(
477
- `\u91CD\u8FDE\u5931\u8D25\uFF1A\u5C1D\u8BD5\u6B21\u6570 ${reconnectAttempts.value} \u5DF2\u8FBE\u5230\u4E0A\u9650 ${maxReconnectAttempts}`
478
- );
479
- return;
480
- }
481
- reconnectAttempts.value++;
482
- const delay = Math.min(1e3 * reconnectAttempts.value, 1e4);
483
- reconnectCoolDown.value = delay;
484
- console.log(`\u5F00\u59CB\u7B2C ${reconnectAttempts.value} \u6B21\u91CD\u8FDE\uFF0C\u5EF6\u8FDF ${delay}ms`);
485
- if (timers.reconnectTimer) {
486
- clearTimeout(timers.reconnectTimer);
137
+ console.log("\u521D\u59CB\u5316\u64AD\u653E\u5668", url);
487
138
  }
488
- timers.reconnectTimer = window.setTimeout(() => {
489
- if (!isPlayerDestroyed.value && playUrl.value) {
490
- initPlayer(playUrl.value);
491
- }
492
- reconnectCoolDown.value = 0;
493
- }, delay);
494
- }
495
- __name(handleReconnect, "handleReconnect");
496
- function createPlayerDom() {
497
139
  removePlayerDom();
498
- if (typeof document !== "undefined" && playerRef.value) {
499
- const container = playerRef.value;
500
- playerRef.value.style.visibility = "visible";
501
- if (!container) {
502
- console.warn("\u64AD\u653E\u5668\u5BB9\u5668\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7DOM\u521B\u5EFA");
503
- return;
504
- }
505
- const dom = document.createElement("div");
506
- const rect = container.getBoundingClientRect();
507
- dom.id = id;
508
- dom.style.width = realFullscreen.value ? "100vw" : `${rect.width}px`;
509
- dom.style.height = realFullscreen.value ? props.areaName || props.deviceSerial ? "calc(100vh - 32px)" : "100vh" : props.areaName || props.deviceSerial ? `${rect.height - 32}px` : `${rect.height}px`;
510
- dom.style.overflow = "hidden";
511
- dom.style.backgroundColor = "#000";
512
- dom.style.transform = "none";
513
- dom.style.willChange = "auto";
514
- dom.style.backfaceVisibility = "visible";
515
- const existingDom = document.getElementById(id);
516
- if (existingDom) {
517
- console.warn(`ID\u4E3A ${id} \u7684\u64AD\u653E\u5668DOM\u5143\u7D20\u5DF2\u5B58\u5728\uFF0C\u5148\u79FB\u9664\u65E7\u5143\u7D20`);
518
- existingDom.remove();
519
- }
520
- if (container && container.parentNode) {
521
- container.appendChild(dom);
522
- } else {
523
- console.warn("\u64AD\u653E\u5668\u5BB9\u5668\u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u9500\u6BC1\uFF0C\u65E0\u6CD5\u6DFB\u52A0\u64AD\u653E\u5668DOM\u5143\u7D20");
524
- }
525
- } else {
526
- console.error("\u64AD\u653E\u5668\u5BB9\u5668\u4E0D\u5B58\u5728\uFF0C\u65E0\u6CD5\u521B\u5EFA\u64AD\u653E\u5668DOM\u5143\u7D20");
527
- }
528
- }
529
- __name(createPlayerDom, "createPlayerDom");
530
- function startMemoryMonitoring() {
531
- if (timers.memoryCheckInterval) {
532
- clearInterval(timers.memoryCheckInterval);
533
- }
534
- if (typeof window === "undefined") return;
535
- timers.memoryCheckInterval = window.setInterval(() => {
536
- checkMemoryUsage();
537
- }, MEMORY_CHECK_INTERVAL);
538
- }
539
- __name(startMemoryMonitoring, "startMemoryMonitoring");
540
- async function checkMemoryUsage() {
541
- if (isPlayerDestroyed.value) return;
542
- try {
543
- let usedMemory = 0;
544
- let gpuMemory = 0;
545
- let jsHeapRatio = 0;
546
- if (performance.memory) {
547
- const memory = performance.memory;
548
- usedMemory = Math.round(memory.usedJSHeapSize / 1024 / 1024);
549
- jsHeapRatio = Math.round(
550
- memory.usedJSHeapSize / memory.totalJSHeapSize * 100
551
- );
552
- } else {
553
- usedMemory = player ? HIGH_MEMORY_THRESHOLD + 20 : 0;
554
- }
555
- if ("gpu" in navigator && navigator.gpu) {
556
- try {
557
- const gpuInfo = navigator.gpu;
558
- if (gpuInfo && gpuInfo.getInfo) {
559
- const info = await gpuInfo.getInfo();
560
- gpuMemory = info.dedicatedVideoMemory ? Math.round(info.dedicatedVideoMemory / 1024 / 1024) : 0;
561
- }
562
- } catch (e) {
563
- gpuMemory = 0;
564
- }
565
- }
566
- const browser = navigator.userAgent.toLowerCase();
567
- let dynamicThreshold = HIGH_MEMORY_THRESHOLD;
568
- if (browser.includes("chrome")) {
569
- dynamicThreshold = 100;
570
- } else if (browser.includes("firefox")) {
571
- dynamicThreshold = 70;
572
- }
573
- const totalEstimate = usedMemory + (gpuMemory || 0);
574
- console.log(
575
- `\u{1F4CA} \u5185\u5B58\u5360\u7528\uFF1AJS-${usedMemory}MB, GPU-${gpuMemory}MB, \u9608\u503C-${dynamicThreshold}MB`
576
- );
577
- if (totalEstimate >= MEMORY_PEAK_THRESHOLD) {
578
- console.warn(`\u26A0\uFE0F \u5185\u5B58\u63A5\u8FD1\u5CF0\u503C\uFF1A${totalEstimate}MB \u2192 \u89E6\u53D1\u65E0\u7F1D\u91CD\u5EFA`);
579
- const now = Date.now();
580
- if (now - lastMemoryPeak > 60 * 1e3) {
581
- seamlessRebuildPlayer();
582
- lastMemoryPeak = now;
583
- }
584
- }
585
- if (totalEstimate > dynamicThreshold || jsHeapRatio > 85) {
586
- emits("memoryWarn", {
587
- used: totalEstimate,
588
- threshold: dynamicThreshold,
589
- details: {
590
- js: usedMemory,
591
- gpu: gpuMemory,
592
- jsHeapRatio
593
- },
594
- timestamp: Date.now()
595
- });
596
- performEmergencyCleanup();
597
- }
598
- if (totalEstimate > 1200) {
599
- console.warn("\u{1F525} \u5185\u5B58\u8D85\u9650\uFF0C\u81EA\u52A8\u5237\u65B0\u9875\u9762");
600
- sessionStorage.setItem("lastPlayUrl", playUrl.value);
601
- window.location.reload();
140
+ if (url) {
141
+ playUrl.value = formatUrl(url);
142
+ if (props.debug) {
143
+ console.log("\u683C\u5F0F\u5316\u540E\u7684url", playUrl.value);
602
144
  }
603
- } catch (e) {
604
- console.warn("\u5185\u5B58\u76D1\u63A7\u5F02\u5E38:", e);
605
- }
606
- }
607
- __name(checkMemoryUsage, "checkMemoryUsage");
608
- function performEmergencyCleanup() {
609
- var _a, _b;
610
- if (isPlayerDestroyed.value) return;
611
- console.log("\u6267\u884C\u7D27\u6025\u5185\u5B58\u6E05\u7406");
612
- if (player && player.hls && player.hls.mediaSource) {
613
- try {
614
- const mediaSource = player.hls.mediaSource;
615
- for (const sourceBuffer of mediaSource.sourceBuffers) {
616
- if (sourceBuffer.updating === false) {
617
- sourceBuffer.remove(0, Infinity).then(() => {
618
- console.log("MSE \u6E90\u7F13\u51B2\u533A\u5DF2\u6E05\u7A7A");
619
- }).catch((e) => console.warn("\u6E05\u7A7AMSE\u7F13\u51B2\u533A\u5931\u8D25:", e));
145
+ if (typeof window !== "undefined" && (window == null ? void 0 : window.EasyPlayerPro)) {
146
+ createPlayer();
147
+ } else if (typeof window !== "undefined") {
148
+ const timer = setInterval(() => {
149
+ if (window == null ? void 0 : window.EasyPlayerPro) {
150
+ createPlayer();
151
+ clearInterval(timer);
620
152
  }
621
- }
622
- if (mediaSource.readyState === "open") {
623
- mediaSource.endOfStream();
624
- setTimeout(() => {
625
- if (mediaSource.sourceBuffers.length > 0) {
626
- mediaSource.removeSourceBuffer(mediaSource.sourceBuffers[0]);
627
- }
628
- }, 100);
629
- }
630
- } catch (e) {
631
- console.warn("MSE \u7F13\u51B2\u533A\u6E05\u7406\u5F02\u5E38:", e);
632
- }
633
- }
634
- if (player) {
635
- (_a = player.clearCache) == null ? void 0 : _a.call(player);
636
- (_b = player.trimBuffer) == null ? void 0 : _b.call(player);
637
- try {
638
- if (player.videoElement) {
639
- player.videoElement.pause();
640
- URL.revokeObjectURL(player.videoElement.src);
641
- player.videoElement.src = "";
642
- player.videoElement.removeAttribute("src");
643
- player.videoElement.innerHTML = "";
644
- player.videoElement.load();
645
- player.videoElement.remove();
646
- }
647
- } catch (e) {
648
- console.warn("\u89C6\u9891\u5143\u7D20\u91CD\u7F6E\u5F02\u5E38:", e);
153
+ }, 100);
649
154
  }
650
155
  }
651
- if (playerRef.value) {
652
- const tempStyle = playerRef.value.style.display;
653
- playerRef.value.style.display = "none";
654
- void playerRef.value.offsetHeight;
655
- playerRef.value.style.display = tempStyle;
656
- }
657
- if (window.gc) {
658
- window.gc();
659
- }
660
- const currentUrl = playUrl.value;
661
- if (currentUrl) {
662
- destroy(false);
663
- setTimeout(() => {
664
- if (currentUrl === playUrl.value) {
665
- isPlayerDestroyed.value = false;
666
- reconnectAttempts.value = 0;
667
- initPlayer(currentUrl);
668
- }
669
- }, EMERGENCY_CLEAN_TIMEOUT);
670
- }
671
156
  }
672
- __name(performEmergencyCleanup, "performEmergencyCleanup");
157
+ __name(initPlayer, "initPlayer");
673
158
  function removePlayerDom() {
674
159
  if (typeof document !== "undefined") {
675
160
  const dom = document.getElementById(id);
@@ -677,114 +162,100 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
677
162
  }
678
163
  }
679
164
  __name(removePlayerDom, "removePlayerDom");
680
- function destroy(isForce = false) {
681
- var _a, _b, _c, _d, _e, _f;
682
- if (isPlayerDestroyed.value && !isForce) return;
683
- isPlayerDestroyed.value = true;
684
- if (player) {
685
- (_a = player.pause) == null ? void 0 : _a.call(player);
686
- (_b = player.stopLoad) == null ? void 0 : _b.call(player);
687
- (_c = player.unload) == null ? void 0 : _c.call(player);
688
- if (player.hls) {
689
- (_e = (_d = player.hls).offAll) == null ? void 0 : _e.call(_d);
690
- }
691
- (_f = player.removeAllListeners) == null ? void 0 : _f.call(player);
692
- eventHandlers.length = 0;
693
- if (player.videoElement) {
694
- player.videoElement.remove();
695
- player.videoElement = null;
696
- }
697
- }
698
- Object.values(timers).forEach((timer) => {
699
- if (timer) {
700
- if (timer.toString().includes("Timeout")) {
701
- clearTimeout(timer);
165
+ function createPlayerDom() {
166
+ removePlayerDom();
167
+ if (typeof document !== "undefined") {
168
+ vue.nextTick(() => {
169
+ var _a;
170
+ const dom = document.createElement("div");
171
+ const { width, height } = playerRef.value.getBoundingClientRect();
172
+ dom.id = id;
173
+ if (realFullscreen.value) {
174
+ dom.style.width = `100vw`;
175
+ dom.style.height = props.areaName || props.deviceSerial ? `calc(100vh - 32px)` : `100vh`;
702
176
  } else {
703
- clearInterval(timer);
177
+ dom.style.width = `${width}px`;
178
+ dom.style.height = props.areaName || props.deviceSerial ? `${height - 32}px` : `${height}px`;
704
179
  }
705
- }
706
- });
707
- removePlayerDom();
708
- if (playerRef.value) {
709
- playerRef.value.style.visibility = "hidden";
180
+ (_a = playerRef.value) == null ? void 0 : _a.appendChild(dom);
181
+ });
710
182
  }
711
- if (window.gc) window.gc();
712
- const tempDisplay = document.body.style.display;
713
- document.body.style.display = "none";
714
- void document.body.offsetHeight;
715
- document.body.style.display = tempDisplay;
716
- player = null;
717
- playSuccess.value = false;
718
- isPlayerIniting.value = false;
719
183
  }
720
- __name(destroy, "destroy");
721
- vue.onBeforeUnmount(() => {
184
+ __name(createPlayerDom, "createPlayerDom");
185
+ async function createPlayer() {
722
186
  if (props.debug) {
723
- console.log("\u7EC4\u4EF6\u5378\u8F7D\uFF1A\u6E05\u7406\u6240\u6709\u8D44\u6E90");
187
+ console.log("\u521B\u5EFA\u64AD\u653E\u5668");
724
188
  }
725
- Object.values(timers).forEach((timer) => {
726
- if (timer) {
727
- if (timer.toString().includes("Timeout")) {
728
- clearTimeout(timer);
729
- } else {
730
- clearInterval(timer);
731
- }
732
- }
733
- });
734
- playUrl.value = "";
735
- isPlayerDestroyed.value = true;
736
- destroy(true);
737
- requestCache.clear();
738
- try {
739
- const canvasElements = document.querySelectorAll("canvas");
740
- canvasElements.forEach((canvas) => {
741
- const ctx = canvas.getContext("webgl") || canvas.getContext("2d");
742
- if (ctx) {
743
- if (ctx.getExtension) {
744
- const ext = ctx.getExtension(
745
- "WEBGL_lose_context"
746
- );
747
- if (ext) {
748
- ext.loseContext();
749
- }
750
- }
751
- if (ctx.clearRect) {
752
- ctx.clearRect(
753
- 0,
754
- 0,
755
- canvas.width,
756
- canvas.height
757
- );
758
- }
759
- }
760
- canvas.remove();
189
+ videoInfo.value = null;
190
+ createPlayerDom();
191
+ await vue.nextTick();
192
+ if (typeof window !== "undefined" && typeof document !== "undefined") {
193
+ player = new window.EasyPlayerPro(document.getElementById(id), {
194
+ isLive: true,
195
+ // 是否直播
196
+ hasAudio: true,
197
+ // 是否解析音频
198
+ bufferTime: 0.2,
199
+ // 缓存时长
200
+ stretch: true,
201
+ // 加视频拉伸
202
+ MSE: false,
203
+ WCS: false,
204
+ WASM: true,
205
+ debug: false,
206
+ operateBtns: {
207
+ performance: false
208
+ },
209
+ autoCleanupSourceBuffer: true,
210
+ //(对 SourceBuffer 进行自动清理)
211
+ autoCleanupMinBackwardDuration: 60
212
+ // (指示在执行自动清理时为后向缓冲区保留的持续时间,以秒为单位)
761
213
  });
762
- window.dispatchEvent(new Event("resize"));
763
- } catch (e) {
764
- console.warn("GPU\u8D44\u6E90\u6E05\u7406\u5F02\u5E38:", e);
765
214
  }
766
- });
767
- __expose({
768
- play,
769
- destroy: /* @__PURE__ */ __name(() => destroy(true), "destroy"),
770
- getPlayer: /* @__PURE__ */ __name(() => player, "getPlayer"),
771
- pause: playerPause,
772
- screenshot: playerScreenShot,
773
- fullscreen: playerFullscreen,
774
- isMute: /* @__PURE__ */ __name(() => {
775
- var _a;
776
- return ((_a = player == null ? void 0 : player.isMute) == null ? void 0 : _a.call(player)) || false;
777
- }, "isMute"),
778
- setMute: /* @__PURE__ */ __name((mute) => {
779
- var _a;
780
- if (player && !isPlayerDestroyed.value) {
781
- (_a = player.setMute) == null ? void 0 : _a.call(player, mute);
782
- }
783
- }, "setMute"),
784
- cleanMemory: /* @__PURE__ */ __name(() => performEmergencyCleanup(), "cleanMemory"),
785
- rebuildPlayer: /* @__PURE__ */ __name(() => seamlessRebuildPlayer(), "rebuildPlayer")
786
- // 暴露手动重建方法
787
- });
215
+ if (player) {
216
+ player.play(playUrl.value);
217
+ player.on("timeout", () => {
218
+ props.debug && console.log("\u52A0\u8F7D\u8D85\u65F6");
219
+ emits("timeout");
220
+ playSuccess.value = false;
221
+ destroy();
222
+ initPlayer(playUrl.value);
223
+ });
224
+ player.on("error", () => {
225
+ props.debug && console.log("\u64AD\u653E\u5F02\u5E38");
226
+ emits("error");
227
+ playSuccess.value = false;
228
+ destroy();
229
+ });
230
+ player.on("play", () => {
231
+ playSuccess.value = true;
232
+ props.debug && console.log("\u64AD\u653E");
233
+ emits("play");
234
+ });
235
+ player.on("pause", () => {
236
+ props.debug && console.log("\u6682\u505C");
237
+ emits("pause");
238
+ });
239
+ player.on("videoInfo", (info) => {
240
+ props.debug && console.log("\u89C6\u9891\u4FE1\u606F", info);
241
+ videoInfo.value = info;
242
+ emits("videoInfo", info);
243
+ });
244
+ player.on("mute", (mute) => {
245
+ props.debug && console.log("\u9759\u97F3");
246
+ emits("mute", mute);
247
+ });
248
+ }
249
+ }
250
+ __name(createPlayer, "createPlayer");
251
+ function destroy() {
252
+ if (player) {
253
+ player.destroy();
254
+ player = null;
255
+ }
256
+ removePlayerDom();
257
+ }
258
+ __name(destroy, "destroy");
788
259
  return (_ctx, _cache) => {
789
260
  return vue.openBlock(), vue.createElementBlock(
790
261
  "div",
@@ -795,7 +266,7 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
795
266
  },
796
267
  [
797
268
  vue.createCommentVNode(" \u64AD\u653E\u5668\u9876\u90E8\u663E\u793A\u533A\u57DF(\u8BBE\u5907)\u540D\u79F0 "),
798
- areaName.value || deviceSerial.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
269
+ _ctx.areaName || _ctx.deviceSerial ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
799
270
  _cache[0] || (_cache[0] = vue.createElementVNode(
800
271
  "i",
801
272
  { class: "iconfont icon-shexiangtou4" },
@@ -806,21 +277,21 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
806
277
  vue.createElementVNode(
807
278
  "span",
808
279
  null,
809
- vue.toDisplayString(areaName.value || deviceSerial.value),
280
+ vue.toDisplayString(_ctx.areaName || _ctx.deviceSerial),
810
281
  1
811
282
  /* TEXT */
812
283
  )
813
284
  ])) : vue.createCommentVNode("v-if", true),
814
285
  !playSuccess.value ? (vue.openBlock(), vue.createBlock(errorPage_vue_vue_type_script_setup_true_lang.default, {
815
286
  key: 1,
816
- "video-name": areaName.value || deviceSerial.value,
287
+ videoName: _ctx.areaName || _ctx.deviceSerial,
817
288
  message: "\u65E0\u4FE1\u53F7"
818
- }, null, 8, ["video-name"])) : vue.createCommentVNode("v-if", true),
289
+ }, null, 8, ["videoName"])) : vue.createCommentVNode("v-if", true),
819
290
  !playUrl.value ? (vue.openBlock(), vue.createBlock(errorPage_vue_vue_type_script_setup_true_lang.default, {
820
291
  key: 2,
821
- "video-name": areaName.value || deviceSerial.value,
292
+ videoName: _ctx.areaName || _ctx.deviceSerial,
822
293
  message: "\u65E0\u64AD\u653E\u5730\u5740"
823
- }, null, 8, ["video-name"])) : vue.createCommentVNode("v-if", true),
294
+ }, null, 8, ["videoName"])) : vue.createCommentVNode("v-if", true),
824
295
  vue.createCommentVNode(" \u64AD\u653E\u5668\u5E95\u90E8\u64CD\u4F5C\u680F "),
825
296
  vue.renderSlot(_ctx.$slots, "customBar")
826
297
  ],