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