@yimou6/common-ui 1.10.7 → 1.10.9

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 (58) hide show
  1. package/cdn/index.cdn.js +30 -17
  2. package/cdn/index.cdn.js.map +1 -1
  3. package/cdn/index.cdn.mjs +28 -15
  4. package/cdn/index.cdn.mjs.map +1 -1
  5. package/cdn/index.css +1 -1
  6. package/es/components/tenant-enterprise/src/tenant-enterprise.vue2.mjs +12 -3
  7. package/es/components/tenant-enterprise/src/tenant-enterprise.vue2.mjs.map +1 -1
  8. package/es/components/tzj-player/index.d.ts +5066 -3
  9. package/es/components/tzj-player/src/easyPlayer.vue.d.ts +104 -8
  10. package/es/components/tzj-player/src/easyPlayer.vue2.mjs +179 -62
  11. package/es/components/tzj-player/src/easyPlayer.vue2.mjs.map +1 -1
  12. package/es/components/tzj-player/src/tzj-player.d.ts +19 -2
  13. package/es/components/tzj-player/src/tzj-player.mjs +47 -1
  14. package/es/components/tzj-player/src/tzj-player.mjs.map +1 -1
  15. package/es/components/tzj-player/src/tzj-player.vue.d.ts +5066 -3
  16. package/es/components/tzj-player/src/tzj-player.vue2.mjs +129 -36
  17. package/es/components/tzj-player/src/tzj-player.vue2.mjs.map +1 -1
  18. package/es/components/tzj-player/src/ysPlayer.vue.d.ts +2 -2
  19. package/es/components/tzj-player/src/ysPlayer.vue2.mjs +40 -29
  20. package/es/components/tzj-player/src/ysPlayer.vue2.mjs.map +1 -1
  21. package/es/components/tzj-player/src/yunzhiyan.d.ts +6 -0
  22. package/es/components/tzj-player/src/yunzhiyan.mjs +306 -0
  23. package/es/components/tzj-player/src/yunzhiyan.mjs.map +1 -0
  24. package/es/components/tzj-player/src/yunzhiyanPlayer.vue.d.ts +1519 -0
  25. package/es/components/tzj-player/src/yunzhiyanPlayer.vue.mjs +6 -0
  26. package/es/components/tzj-player/src/yunzhiyanPlayer.vue.mjs.map +1 -0
  27. package/es/components/tzj-player/src/yunzhiyanPlayer.vue2.mjs +637 -0
  28. package/es/components/tzj-player/src/yunzhiyanPlayer.vue2.mjs.map +1 -0
  29. package/es/utils/provide.d.ts +3 -3
  30. package/es/utils/provide.mjs.map +1 -1
  31. package/lib/components/tenant-enterprise/src/tenant-enterprise.vue2.js +12 -3
  32. package/lib/components/tenant-enterprise/src/tenant-enterprise.vue2.js.map +1 -1
  33. package/lib/components/tzj-player/index.d.ts +5066 -3
  34. package/lib/components/tzj-player/src/easyPlayer.vue.d.ts +104 -8
  35. package/lib/components/tzj-player/src/easyPlayer.vue2.js +177 -60
  36. package/lib/components/tzj-player/src/easyPlayer.vue2.js.map +1 -1
  37. package/lib/components/tzj-player/src/tzj-player.d.ts +19 -2
  38. package/lib/components/tzj-player/src/tzj-player.js +47 -0
  39. package/lib/components/tzj-player/src/tzj-player.js.map +1 -1
  40. package/lib/components/tzj-player/src/tzj-player.vue.d.ts +5066 -3
  41. package/lib/components/tzj-player/src/tzj-player.vue2.js +125 -32
  42. package/lib/components/tzj-player/src/tzj-player.vue2.js.map +1 -1
  43. package/lib/components/tzj-player/src/ysPlayer.vue.d.ts +2 -2
  44. package/lib/components/tzj-player/src/ysPlayer.vue2.js +40 -29
  45. package/lib/components/tzj-player/src/ysPlayer.vue2.js.map +1 -1
  46. package/lib/components/tzj-player/src/yunzhiyan.d.ts +6 -0
  47. package/lib/components/tzj-player/src/yunzhiyan.js +313 -0
  48. package/lib/components/tzj-player/src/yunzhiyan.js.map +1 -0
  49. package/lib/components/tzj-player/src/yunzhiyanPlayer.vue.d.ts +1519 -0
  50. package/lib/components/tzj-player/src/yunzhiyanPlayer.vue.js +10 -0
  51. package/lib/components/tzj-player/src/yunzhiyanPlayer.vue.js.map +1 -0
  52. package/lib/components/tzj-player/src/yunzhiyanPlayer.vue2.js +641 -0
  53. package/lib/components/tzj-player/src/yunzhiyanPlayer.vue2.js.map +1 -0
  54. package/lib/utils/provide.d.ts +3 -3
  55. package/lib/utils/provide.js.map +1 -1
  56. package/package.json +4 -2
  57. package/theme-default/i-tzj-player.css +1 -1
  58. package/theme-default/index.css +1 -1
@@ -0,0 +1,6 @@
1
+ import _sfc_main from './yunzhiyanPlayer.vue2.mjs';
2
+
3
+
4
+
5
+ export { _sfc_main as default };
6
+ //# sourceMappingURL=yunzhiyanPlayer.vue.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yunzhiyanPlayer.vue.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -0,0 +1,637 @@
1
+ import { defineComponent, ref, shallowRef, onMounted, onUnmounted, openBlock, createElementBlock, Fragment, toDisplayString, createBlock, withCtx, createCommentVNode, createElementVNode, normalizeClass } from 'vue';
2
+ import './easyPlayer.vue.mjs';
3
+ import { TzjPlayerProps } from './tzj-player.mjs';
4
+ import { GetYunZhiYanDeviceChannel, GetYunZhiYanDeviceVideoUrl, GetYunZhiYanOpenVoiceIntercom, GetYunZhiYanUserPlaySecretKey, GetYunZhiYanCloseVoiceIntercom } from './yunzhiyan.mjs';
5
+ import _sfc_main$1 from './easyPlayer.vue2.mjs';
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ const _hoisted_1 = {
10
+ key: 0,
11
+ class: "i-tzj-player__error"
12
+ };
13
+ const _hoisted_2 = {
14
+ key: 0,
15
+ class: "i-easy-player-bar"
16
+ };
17
+ const _hoisted_3 = { class: "i-easy-player-bar-item i-easy-player-bar-left" };
18
+ const _hoisted_4 = {
19
+ key: 2,
20
+ class: "i-easy-player-bottom-bar"
21
+ };
22
+ const _hoisted_5 = {
23
+ key: 3,
24
+ class: "i-easy-player-bottom-bar"
25
+ };
26
+ const _hoisted_6 = { class: "i-easy-player-bar-item i-easy-player-bar-right" };
27
+ var _sfc_main = /* @__PURE__ */ defineComponent({
28
+ ...{
29
+ name: "YunzhiyanPlayer"
30
+ },
31
+ __name: "yunzhiyanPlayer",
32
+ props: TzjPlayerProps,
33
+ setup(__props) {
34
+ const props = __props;
35
+ const videoUrl = ref("");
36
+ const errorMsg = ref("");
37
+ const taskId = ref("");
38
+ const showBottomBar = ref(false);
39
+ const playerRef = shallowRef();
40
+ const isPlaying = ref(false);
41
+ const isVoice = ref(false);
42
+ const isFullscreen = ref(false);
43
+ const isVolumeMuted = ref(true);
44
+ const isIntercomActive = ref(false);
45
+ const audioContext = ref(null);
46
+ const mediaStream = ref(null);
47
+ const websocket = ref(null);
48
+ const audioWorkletNode = ref(null);
49
+ const intercomTimer = ref(null);
50
+ const audioMsg = ref({
51
+ type: "",
52
+ msg: ""
53
+ });
54
+ const AUDIO_CONFIG = {
55
+ sampleRate: 48e3,
56
+ channelCount: 1,
57
+ sampleSize: 16
58
+ };
59
+ const initPlayer = /* @__PURE__ */ __name(async () => {
60
+ try {
61
+ if (!props.deviceSerial) {
62
+ errorMsg.value = "\u8BBE\u5907\u5E8F\u5217\u53F7\u4E0D\u80FD\u4E3A\u7A7A";
63
+ return;
64
+ }
65
+ const channelId = await GetYunZhiYanDeviceChannel(props.deviceSerial);
66
+ if (props.debug) {
67
+ console.log("\u83B7\u53D6\u4E91\u667A\u773C\u8BBE\u5907\u901A\u9053ID", channelId);
68
+ }
69
+ if (!channelId) {
70
+ errorMsg.value = "\u83B7\u53D6\u8BBE\u5907\u901A\u9053ID\u5931\u8D25";
71
+ return;
72
+ }
73
+ const url = await GetYunZhiYanDeviceVideoUrl(props.deviceSerial, channelId);
74
+ if (props.debug) {
75
+ console.log("\u83B7\u53D6\u4E91\u667A\u773C\u8BBE\u5907\u89C6\u9891\u64AD\u653E\u5730\u5740", url);
76
+ }
77
+ if (!url) {
78
+ errorMsg.value = "\u83B7\u53D6\u89C6\u9891\u64AD\u653E\u5730\u5740\u5931\u8D25";
79
+ return;
80
+ }
81
+ videoUrl.value = url;
82
+ errorMsg.value = "";
83
+ } catch (error) {
84
+ if (props.debug) {
85
+ console.error("\u521D\u59CB\u5316\u4E91\u667A\u773C\u64AD\u653E\u5668\u5931\u8D25:", error);
86
+ }
87
+ errorMsg.value = `\u521D\u59CB\u5316\u5931\u8D25: ${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`;
88
+ }
89
+ }, "initPlayer");
90
+ const playerPlay = /* @__PURE__ */ __name(() => {
91
+ var _a;
92
+ (_a = playerRef.value) == null ? void 0 : _a.play();
93
+ }, "playerPlay");
94
+ const playerPause = /* @__PURE__ */ __name(() => {
95
+ var _a;
96
+ (_a = playerRef.value) == null ? void 0 : _a.pause();
97
+ }, "playerPause");
98
+ const playerScreenShot = /* @__PURE__ */ __name(() => {
99
+ var _a;
100
+ (_a = playerRef.value) == null ? void 0 : _a.screenshot();
101
+ }, "playerScreenShot");
102
+ const playerFullscreen = /* @__PURE__ */ __name((fullscreen) => {
103
+ var _a;
104
+ isFullscreen.value = fullscreen;
105
+ (_a = playerRef.value) == null ? void 0 : _a.fullscreen(fullscreen);
106
+ }, "playerFullscreen");
107
+ const getAudioUrl = /* @__PURE__ */ __name(async () => {
108
+ try {
109
+ if (!props.deviceSerial) {
110
+ throw new Error("\u8BBE\u5907\u5E8F\u5217\u53F7\u4E0D\u80FD\u4E3A\u7A7A");
111
+ }
112
+ const res = await GetYunZhiYanOpenVoiceIntercom(props.deviceSerial);
113
+ if (props.debug) {
114
+ console.log("\u5F00\u542F\u8BED\u97F3\u5BF9\u8BB2\u54CD\u5E94:", res);
115
+ }
116
+ if (!res) {
117
+ throw new Error("\u5F00\u542F\u8BED\u97F3\u5BF9\u8BB2\u5931\u8D25");
118
+ }
119
+ taskId.value = res.taskId;
120
+ const wssUrl = res.wssUrl;
121
+ if (!taskId.value || !wssUrl) {
122
+ throw new Error("\u83B7\u53D6\u8BED\u97F3\u5BF9\u8BB2\u53C2\u6570\u5931\u8D25");
123
+ }
124
+ const sign = await GetYunZhiYanUserPlaySecretKey(taskId.value);
125
+ if (!sign) {
126
+ throw new Error("\u83B7\u53D6\u7B7E\u540D\u5931\u8D25");
127
+ }
128
+ const url = new URL(wssUrl);
129
+ url.searchParams.append("sign", sign);
130
+ return url.toString();
131
+ } catch (error) {
132
+ if (props.debug) {
133
+ console.error("\u83B7\u53D6\u8BED\u97F3\u5BF9\u8BB2\u5730\u5740\u5931\u8D25:", error);
134
+ }
135
+ throw error;
136
+ }
137
+ }, "getAudioUrl");
138
+ const initAudioContext = /* @__PURE__ */ __name(async () => {
139
+ try {
140
+ if (typeof window === "undefined") {
141
+ throw new Error("\u975E\u6D4F\u89C8\u5668\u73AF\u5883\uFF0C\u65E0\u6CD5\u4F7F\u7528AudioContext");
142
+ }
143
+ const AudioContext = window.AudioContext || window.webkitAudioContext;
144
+ if (!AudioContext) {
145
+ throw new Error("\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301AudioContext");
146
+ }
147
+ audioContext.value = new AudioContext({
148
+ sampleRate: AUDIO_CONFIG.sampleRate
149
+ });
150
+ if (audioContext.value.state === "suspended") {
151
+ await audioContext.value.resume();
152
+ }
153
+ if (props.debug) {
154
+ console.log(
155
+ "\u97F3\u9891\u4E0A\u4E0B\u6587\u521D\u59CB\u5316\u6210\u529F\uFF0C\u91C7\u6837\u7387:",
156
+ audioContext.value.sampleRate
157
+ );
158
+ }
159
+ } catch (error) {
160
+ throw new Error(`\u97F3\u9891\u4E0A\u4E0B\u6587\u521D\u59CB\u5316\u5931\u8D25: ${error}`);
161
+ }
162
+ }, "initAudioContext");
163
+ const initMicrophone = /* @__PURE__ */ __name(async () => {
164
+ try {
165
+ if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
166
+ throw new Error("\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u9EA6\u514B\u98CE\u8BBF\u95EE");
167
+ }
168
+ const constraints = {
169
+ audio: {
170
+ channelCount: AUDIO_CONFIG.channelCount,
171
+ sampleRate: AUDIO_CONFIG.sampleRate,
172
+ echoCancellation: true,
173
+ noiseSuppression: true,
174
+ autoGainControl: true
175
+ },
176
+ video: false
177
+ };
178
+ mediaStream.value = await navigator.mediaDevices.getUserMedia(constraints);
179
+ if (props.debug) {
180
+ console.log("\u9EA6\u514B\u98CE\u521D\u59CB\u5316\u6210\u529F");
181
+ }
182
+ } catch (error) {
183
+ if (error instanceof Error) {
184
+ switch (error.name) {
185
+ case "NotAllowedError":
186
+ throw new Error("\u9EA6\u514B\u98CE\u6743\u9650\u88AB\u62D2\u7EDD\uFF0C\u8BF7\u5141\u8BB8\u8BBF\u95EE\u9EA6\u514B\u98CE");
187
+ case "NotFoundError":
188
+ throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u9EA6\u514B\u98CE\u8BBE\u5907");
189
+ case "NotReadableError":
190
+ throw new Error("\u9EA6\u514B\u98CE\u8BBE\u5907\u88AB\u5176\u4ED6\u5E94\u7528\u5360\u7528");
191
+ case "OverconstrainedError":
192
+ throw new Error("\u9EA6\u514B\u98CE\u8BBE\u5907\u4E0D\u652F\u6301\u6307\u5B9A\u7684\u97F3\u9891\u53C2\u6570");
193
+ default:
194
+ throw new Error(`\u9EA6\u514B\u98CE\u521D\u59CB\u5316\u5931\u8D25: ${error.message}`);
195
+ }
196
+ }
197
+ throw new Error(`\u9EA6\u514B\u98CE\u521D\u59CB\u5316\u5931\u8D25: ${error}`);
198
+ }
199
+ }, "initMicrophone");
200
+ const connectWebSocket = /* @__PURE__ */ __name(async (url) => {
201
+ return new Promise((resolve, reject) => {
202
+ try {
203
+ websocket.value = new WebSocket(url);
204
+ websocket.value.binaryType = "arraybuffer";
205
+ let isResolved = false;
206
+ websocket.value.onopen = () => {
207
+ if (props.debug) {
208
+ console.log("WebSocket\u8FDE\u63A5\u6210\u529F");
209
+ }
210
+ if (!isResolved) {
211
+ isResolved = true;
212
+ resolve();
213
+ }
214
+ };
215
+ websocket.value.onerror = (error) => {
216
+ if (props.debug) {
217
+ console.error("WebSocket\u8FDE\u63A5\u9519\u8BEF:", error);
218
+ }
219
+ if (!isResolved) {
220
+ isResolved = true;
221
+ reject(new Error("WebSocket\u8FDE\u63A5\u5931\u8D25"));
222
+ }
223
+ };
224
+ websocket.value.onclose = (event) => {
225
+ if (props.debug) {
226
+ console.log("WebSocket\u8FDE\u63A5\u5173\u95ED:", event.code, event.reason);
227
+ }
228
+ if (isIntercomActive.value) {
229
+ isIntercomActive.value = false;
230
+ isVoice.value = false;
231
+ }
232
+ };
233
+ websocket.value.onmessage = (event) => {
234
+ if (props.debug) {
235
+ console.log("\u6536\u5230\u670D\u52A1\u7AEF\u6D88\u606F:", event.data);
236
+ }
237
+ };
238
+ const timeoutId = setTimeout(() => {
239
+ var _a, _b;
240
+ if (!isResolved && ((_a = websocket.value) == null ? void 0 : _a.readyState) !== WebSocket.OPEN) {
241
+ isResolved = true;
242
+ (_b = websocket.value) == null ? void 0 : _b.close();
243
+ reject(new Error("WebSocket\u8FDE\u63A5\u8D85\u65F6"));
244
+ }
245
+ }, 1e4);
246
+ if (websocket.value) {
247
+ const originalOnOpen = websocket.value.onopen;
248
+ const originalOnError = websocket.value.onerror;
249
+ websocket.value.onopen = function(event) {
250
+ clearTimeout(timeoutId);
251
+ originalOnOpen == null ? void 0 : originalOnOpen.call(this, event);
252
+ };
253
+ websocket.value.onerror = function(event) {
254
+ clearTimeout(timeoutId);
255
+ originalOnError == null ? void 0 : originalOnError.call(this, event);
256
+ };
257
+ }
258
+ } catch (error) {
259
+ reject(new Error(`WebSocket\u521B\u5EFA\u5931\u8D25: ${error}`));
260
+ }
261
+ });
262
+ }, "connectWebSocket");
263
+ const convertToPCM16 = /* @__PURE__ */ __name((float32Array) => {
264
+ const buffer = new ArrayBuffer(float32Array.length * 2);
265
+ const view = new DataView(buffer);
266
+ for (let i = 0; i < float32Array.length; i++) {
267
+ const sample = Math.max(-1, Math.min(1, float32Array[i]));
268
+ const intSample = sample < 0 ? sample * 32768 : sample * 32767;
269
+ view.setInt16(i * 2, intSample, true);
270
+ }
271
+ return buffer;
272
+ }, "convertToPCM16");
273
+ const startAudioProcessing = /* @__PURE__ */ __name(async () => {
274
+ try {
275
+ if (!audioContext.value || !mediaStream.value) {
276
+ throw new Error("\u97F3\u9891\u4E0A\u4E0B\u6587\u6216\u5A92\u4F53\u6D41\u672A\u521D\u59CB\u5316");
277
+ }
278
+ const sourceNode = audioContext.value.createMediaStreamSource(
279
+ mediaStream.value
280
+ );
281
+ const bufferSize = 4096;
282
+ const processor = audioContext.value.createScriptProcessor(
283
+ bufferSize,
284
+ 1,
285
+ 1
286
+ );
287
+ processor.onaudioprocess = (event) => {
288
+ if (!isIntercomActive.value || !websocket.value || websocket.value.readyState !== WebSocket.OPEN) {
289
+ return;
290
+ }
291
+ try {
292
+ const inputBuffer = event.inputBuffer;
293
+ const inputData = inputBuffer.getChannelData(0);
294
+ if (inputData.length === 0) {
295
+ return;
296
+ }
297
+ const pcmData = convertToPCM16(inputData);
298
+ websocket.value.send(pcmData);
299
+ } catch (error) {
300
+ if (props.debug) {
301
+ console.error("\u97F3\u9891\u6570\u636E\u5904\u7406\u9519\u8BEF:", error);
302
+ }
303
+ }
304
+ };
305
+ sourceNode.connect(processor);
306
+ processor.connect(audioContext.value.destination);
307
+ audioWorkletNode.value = processor;
308
+ if (props.debug) {
309
+ console.log("\u97F3\u9891\u6570\u636E\u5904\u7406\u5F00\u59CB");
310
+ }
311
+ } catch (error) {
312
+ throw new Error(`\u97F3\u9891\u6570\u636E\u5904\u7406\u542F\u52A8\u5931\u8D25: ${error}`);
313
+ }
314
+ }, "startAudioProcessing");
315
+ const stopIntercom = /* @__PURE__ */ __name(async () => {
316
+ try {
317
+ if (props.debug) {
318
+ console.log("\u6B63\u5728\u505C\u6B62\u8BED\u97F3\u5BF9\u8BB2...");
319
+ }
320
+ isVoice.value = false;
321
+ isIntercomActive.value = false;
322
+ if (intercomTimer.value) {
323
+ clearTimeout(intercomTimer.value);
324
+ intercomTimer.value = null;
325
+ }
326
+ if (props.deviceSerial && taskId.value) {
327
+ try {
328
+ await GetYunZhiYanCloseVoiceIntercom(props.deviceSerial, taskId.value);
329
+ } catch (error) {
330
+ if (props.debug) {
331
+ console.error("\u5173\u95ED\u670D\u52A1\u7AEF\u8BED\u97F3\u5BF9\u8BB2\u5931\u8D25:", error);
332
+ }
333
+ }
334
+ }
335
+ if (websocket.value) {
336
+ if (websocket.value.readyState === WebSocket.OPEN) {
337
+ websocket.value.close(1e3, "\u7528\u6237\u4E3B\u52A8\u5173\u95ED");
338
+ }
339
+ websocket.value = null;
340
+ }
341
+ if (mediaStream.value) {
342
+ mediaStream.value.getTracks().forEach((track) => {
343
+ track.stop();
344
+ });
345
+ mediaStream.value = null;
346
+ }
347
+ if (audioContext.value && audioContext.value.state !== "closed") {
348
+ try {
349
+ await audioContext.value.close();
350
+ } catch (error) {
351
+ if (props.debug) {
352
+ console.error("\u5173\u95ED\u97F3\u9891\u4E0A\u4E0B\u6587\u5931\u8D25:", error);
353
+ }
354
+ }
355
+ audioContext.value = null;
356
+ }
357
+ if (audioWorkletNode.value) {
358
+ try {
359
+ audioWorkletNode.value.disconnect();
360
+ } catch (error) {
361
+ if (props.debug) {
362
+ console.error("\u65AD\u5F00\u97F3\u9891\u5DE5\u4F5C\u8282\u70B9\u5931\u8D25:", error);
363
+ }
364
+ }
365
+ audioWorkletNode.value = null;
366
+ }
367
+ taskId.value = "";
368
+ audioMsg.value = {
369
+ type: "",
370
+ msg: ""
371
+ };
372
+ if (props.debug) {
373
+ console.log("\u8BED\u97F3\u5BF9\u8BB2\u5DF2\u505C\u6B62");
374
+ }
375
+ } catch (error) {
376
+ if (props.debug) {
377
+ console.error("\u505C\u6B62\u8BED\u97F3\u5BF9\u8BB2\u65F6\u53D1\u751F\u9519\u8BEF:", error);
378
+ }
379
+ }
380
+ }, "stopIntercom");
381
+ const handleVideoInfo = /* @__PURE__ */ __name(() => {
382
+ var _a;
383
+ isVolumeMuted.value = (_a = playerRef.value) == null ? void 0 : _a.isMute();
384
+ }, "handleVideoInfo");
385
+ const handleMute = /* @__PURE__ */ __name((mute) => {
386
+ isVolumeMuted.value = mute;
387
+ }, "handleMute");
388
+ const handleSetMute = /* @__PURE__ */ __name((volume) => {
389
+ var _a;
390
+ (_a = playerRef.value) == null ? void 0 : _a.setMute(volume);
391
+ }, "handleSetMute");
392
+ const intercom = /* @__PURE__ */ __name(async () => {
393
+ try {
394
+ if (props.debug) {
395
+ console.log("\u5F00\u59CB\u8BED\u97F3\u5BF9\u8BB2...");
396
+ }
397
+ audioMsg.value = {
398
+ type: "info",
399
+ msg: "\u6B63\u5728\u8FDE\u63A5..."
400
+ };
401
+ if (isIntercomActive.value) {
402
+ if (props.debug) {
403
+ console.warn("\u8BED\u97F3\u5BF9\u8BB2\u5DF2\u5728\u8FDB\u884C\u4E2D");
404
+ }
405
+ return;
406
+ }
407
+ isVoice.value = true;
408
+ if (props.debug) {
409
+ console.log("\u6B63\u5728\u83B7\u53D6\u8BED\u97F3\u63A8\u9001\u5730\u5740...");
410
+ }
411
+ const audioUrl = await getAudioUrl();
412
+ if (props.debug) {
413
+ console.log("\u8BED\u97F3\u63A8\u9001\u5730\u5740:", audioUrl);
414
+ }
415
+ await initAudioContext();
416
+ await initMicrophone();
417
+ await connectWebSocket(audioUrl);
418
+ await startAudioProcessing();
419
+ isIntercomActive.value = true;
420
+ if (isVolumeMuted.value) {
421
+ handleSetMute(0);
422
+ }
423
+ audioMsg.value = {
424
+ type: "success",
425
+ msg: "\u8BED\u97F3\u5BF9\u8BB2..."
426
+ };
427
+ intercomTimer.value = setTimeout(async () => {
428
+ if (props.debug) {
429
+ console.log("\u8BED\u97F3\u5BF9\u8BB230\u79D2\u65F6\u95F4\u5230\uFF0C\u81EA\u52A8\u505C\u6B62");
430
+ }
431
+ await stopIntercom();
432
+ }, 3e4);
433
+ if (props.debug) {
434
+ console.log("\u8BED\u97F3\u5BF9\u8BB2\u542F\u52A8\u6210\u529F");
435
+ }
436
+ } catch (error) {
437
+ if (props.debug) {
438
+ console.error("\u8BED\u97F3\u5BF9\u8BB2\u542F\u52A8\u5931\u8D25:", error);
439
+ }
440
+ await stopIntercom();
441
+ audioMsg.value = {
442
+ type: "error",
443
+ msg: "\u8BED\u97F3\u5BF9\u8BB2\u542F\u52A8\u5931\u8D25"
444
+ };
445
+ setTimeout(() => {
446
+ audioMsg.value = {
447
+ type: "",
448
+ msg: ""
449
+ };
450
+ }, 3e3);
451
+ }
452
+ }, "intercom");
453
+ onMounted(() => {
454
+ initPlayer();
455
+ });
456
+ onUnmounted(() => {
457
+ if (isIntercomActive.value) {
458
+ stopIntercom();
459
+ }
460
+ });
461
+ return (_ctx, _cache) => {
462
+ return openBlock(), createElementBlock(
463
+ Fragment,
464
+ null,
465
+ [
466
+ errorMsg.value ? (openBlock(), createElementBlock(
467
+ "div",
468
+ _hoisted_1,
469
+ toDisplayString(errorMsg.value),
470
+ 1
471
+ /* TEXT */
472
+ )) : videoUrl.value ? (openBlock(), createBlock(_sfc_main$1, {
473
+ key: 1,
474
+ ref_key: "playerRef",
475
+ ref: playerRef,
476
+ url: videoUrl.value,
477
+ debug: _ctx.debug,
478
+ "access-token": _ctx.accessToken,
479
+ "platform-type-name": _ctx.platformTypeName,
480
+ "device-serial": _ctx.deviceSerial,
481
+ onMouseenter: _cache[4] || (_cache[4] = ($event) => showBottomBar.value = true),
482
+ onMouseleave: _cache[5] || (_cache[5] = ($event) => showBottomBar.value = false),
483
+ onPause: _cache[6] || (_cache[6] = ($event) => isPlaying.value = false),
484
+ onPlay: _cache[7] || (_cache[7] = ($event) => isPlaying.value = true),
485
+ onVideoInfo: handleVideoInfo,
486
+ onMute: handleMute
487
+ }, {
488
+ customBar: withCtx(() => [
489
+ showBottomBar.value ? (openBlock(), createElementBlock("div", _hoisted_2, [
490
+ createCommentVNode(" \u5DE6\u4FA7\uFF1A\u64AD\u653E/\u6682\u505C "),
491
+ createElementVNode("div", _hoisted_3, [
492
+ createCommentVNode(" \u64AD\u653E "),
493
+ !isPlaying.value ? (openBlock(), createElementBlock("div", {
494
+ key: 0,
495
+ class: "i-easy-player-bottom-bar",
496
+ onClick: playerPlay
497
+ }, _cache[8] || (_cache[8] = [
498
+ createElementVNode(
499
+ "i",
500
+ { class: "iconfont icon-playfill" },
501
+ null,
502
+ -1
503
+ /* CACHED */
504
+ )
505
+ ]))) : (openBlock(), createElementBlock(
506
+ Fragment,
507
+ { key: 1 },
508
+ [
509
+ createCommentVNode(" \u6682\u505C "),
510
+ createElementVNode("div", {
511
+ class: "i-easy-player-bottom-bar",
512
+ onClick: playerPause
513
+ }, _cache[9] || (_cache[9] = [
514
+ createElementVNode(
515
+ "i",
516
+ { class: "iconfont icon-stop" },
517
+ null,
518
+ -1
519
+ /* CACHED */
520
+ )
521
+ ]))
522
+ ],
523
+ 2112
524
+ /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
525
+ )),
526
+ !isVolumeMuted.value ? (openBlock(), createElementBlock("div", _hoisted_4, [
527
+ createCommentVNode(" \u97F3\u91CF\u56FE\u6807 "),
528
+ createElementVNode("i", {
529
+ class: "iconfont icon-notificationfill",
530
+ onClick: _cache[0] || (_cache[0] = ($event) => handleSetMute(1))
531
+ })
532
+ ])) : (openBlock(), createElementBlock("div", _hoisted_5, [
533
+ createCommentVNode(" \u9759\u97F3\u56FE\u6807 "),
534
+ createElementVNode("i", {
535
+ class: "iconfont icon-notificationforbidfill",
536
+ onClick: _cache[1] || (_cache[1] = ($event) => handleSetMute(0))
537
+ })
538
+ ]))
539
+ ]),
540
+ createCommentVNode(" \u622A\u56FE,\u5168\u5C4F "),
541
+ createElementVNode("div", _hoisted_6, [
542
+ createCommentVNode(" \u8BED\u97F3\u5BF9\u8BB2:\u5173\u95ED\u72B6\u6001 "),
543
+ !isVoice.value ? (openBlock(), createElementBlock("div", {
544
+ key: 0,
545
+ class: "i-easy-player-bottom-bar",
546
+ onClick: intercom
547
+ }, _cache[10] || (_cache[10] = [
548
+ createElementVNode(
549
+ "i",
550
+ { class: "iconfont icon-voice" },
551
+ null,
552
+ -1
553
+ /* CACHED */
554
+ )
555
+ ]))) : createCommentVNode("v-if", true),
556
+ createCommentVNode(" \u8BED\u97F3\u5BF9\u8BB2:\u5F00\u542F\u72B6\u6001 "),
557
+ isVoice.value ? (openBlock(), createElementBlock("div", {
558
+ key: 1,
559
+ class: "i-easy-player-bottom-bar",
560
+ onClick: stopIntercom
561
+ }, _cache[11] || (_cache[11] = [
562
+ createElementVNode(
563
+ "i",
564
+ { class: "iconfont icon-voicefill" },
565
+ null,
566
+ -1
567
+ /* CACHED */
568
+ )
569
+ ]))) : createCommentVNode("v-if", true),
570
+ createCommentVNode(" \u622A\u56FE "),
571
+ createElementVNode("div", {
572
+ class: "i-easy-player-bottom-bar",
573
+ onClick: playerScreenShot
574
+ }, _cache[12] || (_cache[12] = [
575
+ createElementVNode(
576
+ "i",
577
+ { class: "iconfont icon-picfill" },
578
+ null,
579
+ -1
580
+ /* CACHED */
581
+ )
582
+ ])),
583
+ createCommentVNode(" \u5168\u5C4F "),
584
+ !isFullscreen.value ? (openBlock(), createElementBlock("div", {
585
+ key: 2,
586
+ class: "i-easy-player-bottom-bar",
587
+ onClick: _cache[2] || (_cache[2] = ($event) => playerFullscreen(true))
588
+ }, _cache[13] || (_cache[13] = [
589
+ createElementVNode(
590
+ "i",
591
+ { class: "iconfont icon-full" },
592
+ null,
593
+ -1
594
+ /* CACHED */
595
+ )
596
+ ]))) : createCommentVNode("v-if", true),
597
+ createCommentVNode(" \u53D6\u6D88\u5168\u5C4F "),
598
+ isFullscreen.value ? (openBlock(), createElementBlock("div", {
599
+ key: 3,
600
+ class: "i-easy-player-bottom-bar",
601
+ onClick: _cache[3] || (_cache[3] = ($event) => playerFullscreen(false))
602
+ }, _cache[14] || (_cache[14] = [
603
+ createElementVNode(
604
+ "i",
605
+ { class: "iconfont icon-reduction" },
606
+ null,
607
+ -1
608
+ /* CACHED */
609
+ )
610
+ ]))) : createCommentVNode("v-if", true)
611
+ ])
612
+ ])) : createCommentVNode("v-if", true)
613
+ ]),
614
+ _: 1
615
+ /* STABLE */
616
+ }, 8, ["url", "debug", "access-token", "platform-type-name", "device-serial"])) : createCommentVNode("v-if", true),
617
+ createCommentVNode(" \u8BED\u97F3\u5BF9\u8BB2\u9519\u8BEF\u63D0\u793A "),
618
+ audioMsg.value.msg ? (openBlock(), createElementBlock(
619
+ "div",
620
+ {
621
+ key: 2,
622
+ class: normalizeClass(["i-tzj-player__voice-default", `i-tzj-player__voice-${audioMsg.value.type}`])
623
+ },
624
+ toDisplayString(audioMsg.value.msg),
625
+ 3
626
+ /* TEXT, CLASS */
627
+ )) : createCommentVNode("v-if", true)
628
+ ],
629
+ 64
630
+ /* STABLE_FRAGMENT */
631
+ );
632
+ };
633
+ }
634
+ });
635
+
636
+ export { _sfc_main as default };
637
+ //# sourceMappingURL=yunzhiyanPlayer.vue2.mjs.map