Commit 88e658ee authored by lei's avatar lei

1111

parent a2d138a9
......@@ -21,7 +21,6 @@ import fullScreen from '@/utils/full'
const serviceUrl = import.meta.env.VITE_VIDEO_URL;
const apiUrl = import.meta.env.VITE_SERVICE_URL;
const webSocketUrl = import.meta.env.VITE_WEBSOCKET_URL;
......@@ -73,10 +72,7 @@ const getCameraList = async () => {
await api_getCameraList(params).then(res => {
if (res.data.code === 200) {
cameraList.value = res.data.data.records;
if (cameraList.value.length > 0) {
cId.value = cameraList.value[0].id; // 设置默认选中ID
switchVideoPalyer(cameraList.value[0].id);
}
cameraList.value.length > 0 && switchVideoPalyer(cameraList.value[0].id);
}
});
};
......@@ -87,7 +83,6 @@ const audioId = ref('');
const playAudio = async (id: string) => {
// 创建新的音频元素并播放
const audio = new Audio(`${apiUrl}/v1/play/${id}`);
audio.play();
// 保留原始逻辑备用
......@@ -103,6 +98,7 @@ const switchVideoPalyer = (id: string) => {
cId.value = id;
let camera = cameraList.value.filter(item => item?.id === id)[0];
console.log("======================================= id", id, camera?.cameraAddress);
// if (!camera?.cameraAddress?.includes('rtsp://')) {
// return message.error('摄像头流地址格式有误!');
......@@ -126,6 +122,7 @@ const switchVideoPalyer = (id: string) => {
}
);
} catch (e) {
console.log("======================================= error", e);
}
});
};
......@@ -163,6 +160,7 @@ const options = [
}
];
const handleSelect = (key: string) => {
console.log(key);
};
// 变更状态
......@@ -204,6 +202,7 @@ let cLogInfo = reactive({});
// 切换视频播放源头
const switchVideoPlayer = () => {
console.log("switchVideoPlayer ==============", "rtsp://admin:gemho10-7@192.168.0.56:554/h264/ch1/main/av_stream`")
// nextTick(() => {
// try {
// // 临时测试
......@@ -282,13 +281,14 @@ onMounted(() => {
try {
let ws = new WebSocket(`${webSocketUrl}/ws/${localStg.get('id')}`);
// 应改为(测试用临时方案):
// let ws = new WebSocket(`ws://localhost:9999/ws/${localStg.get('id')}`);
ws.onopen = function () {
console.log('WebSocket connected --------------------------------------------------------------------------');
ws.send('Hello, Server! ------------------------- ');
};
ws.onmessage = function (event) {
console.log('---------------------- WebSocket received message:', JSON.parse(event.data));
let data = JSON.parse(event.data);
data.algorithmId && playAudio(data.algorithmId);
......@@ -356,14 +356,15 @@ onMounted(() => {
};
ws.onclose = function () {
console.log('WebSocket closed');
};
ws.onerror = function (error) {
console.error('WebSocket error:', error); // 检查控制台是否有连接错误
console.error('WebSocket error:', error);
};
} catch (e) {
console.log(e,'error')
console.log("error", e)
}
......@@ -554,7 +555,7 @@ onMounted(() => {
<template #header-extra>
<div style="width: 200px;">
<NSelect v-model:value="cId" @update:value="val => switchVideoPalyer(val)" placeholder="请选择" label-field="cameraName"
<NSelect @update:value="val => switchVideoPalyer(val)" placeholder="请选择" label-field="cameraName"
value-field="id" :options="cameraList"></NSelect>
</div>
</template>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment