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