|
|
@@ -80,12 +80,13 @@
|
|
|
</div>
|
|
|
<div class="video">
|
|
|
<div class="video_box" v-for="(item, index) in videoList" :key="index">
|
|
|
- <div class="box_mask">无信号</div>
|
|
|
- <div
|
|
|
- v-show="item.isShow"
|
|
|
+ <video
|
|
|
+ :src="item.url"
|
|
|
+ controls
|
|
|
+ muted
|
|
|
+ autoplay
|
|
|
class="box_video"
|
|
|
- :id="index + 'Watch'"
|
|
|
- ></div>
|
|
|
+ ></video>
|
|
|
<div class="box_name">{{ item.title }}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -99,10 +100,7 @@ import { useRouter } from "vue-router";
|
|
|
import { countUpNum } from "@/utils/countUpNum";
|
|
|
import { reqGetSmartWarning } from "@/api/school/index";
|
|
|
// @ts-ignore
|
|
|
-import { reqVideoLogin } from "@/api/video/index";
|
|
|
-// @ts-ignore
|
|
|
-import WasmPlayer from "@easydarwin/easywasmplayer";
|
|
|
-import axios from "axios";
|
|
|
+import { reqVideoLogin, reqVideoPull, reqVideoStop } from "@/api/video/index";
|
|
|
|
|
|
// 监控摄像头数据
|
|
|
const deviceNum = ref(150);
|
|
|
@@ -121,7 +119,7 @@ const deviceDom3 = ref();
|
|
|
const tableData = ref([]);
|
|
|
|
|
|
// 路由器实例
|
|
|
-const router = useRouter();
|
|
|
+const $router = useRouter();
|
|
|
|
|
|
// 当前页
|
|
|
const currentPage = ref(1);
|
|
|
@@ -131,37 +129,27 @@ const pageCount = ref(10);
|
|
|
// 监控列表
|
|
|
const videoList = ref<any>([
|
|
|
{
|
|
|
- show: false,
|
|
|
title: "大门口1",
|
|
|
- url: "ws://172.16.7.203:8081/1ive/c70_1.1ive.flv",
|
|
|
- timer: null,
|
|
|
+ url: "https://www.campussmartlife.com/wzszlocalvideozlm/live/c70_1.live.mp4",
|
|
|
+ d: "D70",
|
|
|
},
|
|
|
{
|
|
|
- show: false,
|
|
|
title: "大门口2",
|
|
|
- url: "ws://172.16.7.203:8081/1ive/c68_1.1ive.flv",
|
|
|
- timer: null,
|
|
|
+ url: "https://www.campussmartlife.com/wzszlocalvideozlm/live/c68_1.live.mp4",
|
|
|
+ d: "D68",
|
|
|
},
|
|
|
{
|
|
|
- show: false,
|
|
|
title: "前操场1",
|
|
|
- url: "ws://172.16.7.203:8081/1ive/c118_1.1ive.flv",
|
|
|
- timer: null,
|
|
|
+ url: "https://www.campussmartlife.com/wzszlocalvideozlm/live/c118_1.live.mp4",
|
|
|
+ d: "D118",
|
|
|
},
|
|
|
{
|
|
|
- show: false,
|
|
|
title: "前操场2",
|
|
|
- url: "ws://172.16.7.203:8081/1ive/c120_1.1ive.flv",
|
|
|
- timer: null,
|
|
|
+ url: "https://www.campussmartlife.com/wzszlocalvideozlm/live/c120_1.live.mp4",
|
|
|
+ d: "D120",
|
|
|
},
|
|
|
]);
|
|
|
|
|
|
-// 延时器实例数组
|
|
|
-const timerList = ref<any>([]);
|
|
|
-
|
|
|
-// 监控实例数组
|
|
|
-const playerList = ref<any>([]);
|
|
|
-
|
|
|
onMounted(() => {
|
|
|
// 让数字动起来
|
|
|
getCountUpNum();
|
|
|
@@ -170,17 +158,15 @@ onMounted(() => {
|
|
|
getSmartWarning();
|
|
|
|
|
|
// 登录获取监控权限
|
|
|
- // getVideoLogin();
|
|
|
+ getVideoLogin();
|
|
|
|
|
|
- // 初始化监控
|
|
|
+ // 拉流
|
|
|
initVideo();
|
|
|
});
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
- // 销毁WasmPlayer实例
|
|
|
- destroyVideos();
|
|
|
- // 销毁延时器实例
|
|
|
- destroyTimers();
|
|
|
+ // 关流
|
|
|
+ stopVideo();
|
|
|
});
|
|
|
|
|
|
// 获取预警推送信息
|
|
|
@@ -197,69 +183,40 @@ const getSmartWarning = async () => {
|
|
|
|
|
|
// 登录获取监控权限
|
|
|
const getVideoLogin = async () => {
|
|
|
- console.log(111);
|
|
|
-
|
|
|
- // const res = await reqVideoLogin({
|
|
|
- // username: "admin",
|
|
|
- // password: "admin.123456",
|
|
|
- // });
|
|
|
- // console.log(res);
|
|
|
-
|
|
|
- // const res = await axios({
|
|
|
- // url: "http://172.16.7.203:8083/av_ja/videoAdmin/login",
|
|
|
- // method: "post",
|
|
|
- // data: {
|
|
|
- // username: "admin",
|
|
|
- // password: "admin.123456",
|
|
|
- // },
|
|
|
- // });
|
|
|
+ const res = await reqVideoLogin({
|
|
|
+ username: "admin",
|
|
|
+ password: "admin.123456",
|
|
|
+ });
|
|
|
// console.log(res);
|
|
|
+ localStorage.setItem("admin_token", res.data.token);
|
|
|
};
|
|
|
|
|
|
+// 拉流
|
|
|
const initVideo = () => {
|
|
|
- videoList.value.forEach((ele: any, index: number) => {
|
|
|
- let player = new WasmPlayer(null, index + "Watch", (a: any) => {
|
|
|
- // a表示当前播放的状态
|
|
|
- if (a === "videoTimestamp") {
|
|
|
- ele.isShow = true;
|
|
|
- } else {
|
|
|
- // 开启一个延时10秒的延时器
|
|
|
- if (!ele.timer) {
|
|
|
- (ele.timer as any) = setTimeout(() => {
|
|
|
- // 如果isShow为false表示播放失败,此时断开连接节约性能
|
|
|
- if (!ele.isShow) {
|
|
|
- player.destroy();
|
|
|
- }
|
|
|
-
|
|
|
- // 收集延时器实例方便后面销毁
|
|
|
- timerList.value.push(ele.timer);
|
|
|
- }, 10000);
|
|
|
- }
|
|
|
- }
|
|
|
+ videoList.value.forEach(async (ele: any) => {
|
|
|
+ await reqVideoPull({
|
|
|
+ d: ele.d,
|
|
|
+ nowLine: "1",
|
|
|
+ isNvr: "1",
|
|
|
});
|
|
|
- player.play(ele.url, 1);
|
|
|
-
|
|
|
- // 收集监控实例方便后面销毁
|
|
|
- playerList.value.push(player);
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 查看更多按钮回调
|
|
|
const handleCheckMore = () => {
|
|
|
- router.push("/more");
|
|
|
-};
|
|
|
+ // 关流
|
|
|
+ stopVideo();
|
|
|
|
|
|
-// 销毁WasmPlayer实例
|
|
|
-const destroyVideos = () => {
|
|
|
- playerList.value.forEach((ele: any) => {
|
|
|
- ele.destroy();
|
|
|
- });
|
|
|
+ $router.push("/more");
|
|
|
};
|
|
|
|
|
|
-// 销毁延时器实例
|
|
|
-const destroyTimers = () => {
|
|
|
- timerList.value.forEach((ele: any) => {
|
|
|
- clearTimeout(ele);
|
|
|
+// 关流
|
|
|
+const stopVideo = () => {
|
|
|
+ videoList.value.forEach(async (ele: any) => {
|
|
|
+ await reqVideoStop({
|
|
|
+ d: ele.d,
|
|
|
+ nowLine: "1",
|
|
|
+ });
|
|
|
});
|
|
|
};
|
|
|
|
|
|
@@ -388,22 +345,9 @@ const getCountUpNum = () => {
|
|
|
height: 134px;
|
|
|
border-radius: 5px;
|
|
|
|
|
|
- .box_mask {
|
|
|
- position: absolute;
|
|
|
- top: 0;
|
|
|
- width: 100%;
|
|
|
- height: 100%;
|
|
|
- display: flex;
|
|
|
- justify-content: center;
|
|
|
- align-items: center;
|
|
|
- font-size: 16px;
|
|
|
- background-color: #000;
|
|
|
- }
|
|
|
-
|
|
|
.box_video {
|
|
|
width: 198px;
|
|
|
height: 134px;
|
|
|
- background-color: rgba($color: #000000, $alpha: 0.3);
|
|
|
}
|
|
|
|
|
|
.box_name {
|
|
|
@@ -414,7 +358,7 @@ const getCountUpNum = () => {
|
|
|
width: 100%;
|
|
|
height: 30px;
|
|
|
font-size: 16px;
|
|
|
- background-color: rgba($color: #fff, $alpha: 0.1);
|
|
|
+ background-color: rgba($color: #000, $alpha: 0.5);
|
|
|
}
|
|
|
}
|
|
|
}
|