dbsd_kczx/src/views/kc/jiaoshi/index.vue

257 lines
8.7 KiB
Vue
Raw Normal View History

2023-04-21 00:41:02 +08:00
<template>
<div style="width:100%;height: 100%;">
<a-row>
<a-col :span="4">
<a-menu
v-model:openKeys="openKeys"
v-model:selectedKeys="selectedKeys"
style="overflow: hidden;overflow-y:scroll"
:style="{ height: `calc(100vh - ${topWidth})`, borderRight: 0 }"
mode="inline"
>
<a-menu-item v-for="(item, index) of leftList" :key="index" @click="(e) => titleClick(e,item)" :title="`${item.jsmc}-${item.xm}`">
{{ item.jsmc }}-{{ item.xm }}
</a-menu-item>
</a-menu>
<!-- document.querySelector('.ant-layout .jeecg-default-layout-main > div').style.height -->
</a-col>
<a-col :span="20">
2023-04-22 15:16:05 +08:00
<!-- <a-row> -->
<!-- <a-col :span="12" v-if="currentItem?.child?.录播主机">
<div>{{ currentItem?.child?.录播主机?.xm }}</div>
<bVideo :ref="el=> bVideoRefs['main']=el" :videoOption="{ autoPlay: true }" :videoKey="'main'"/>
</a-col> -->
<!-- <a-col :span="12">
<a-row>
<a-col v-for="(item,index) of calcOtherVideo()" :span="12">
<div>{{ index }}</div>
<bVideo :ref="el=> bVideoRefs[index]=el" :videoOption="{ autoPlay: true }" :videoKey="'other-'+item.id"/>
</a-col>
</a-row>
</a-col> -->
<!-- <a-col v-for="(item,index) of calcOtherVideo()" :span="4">
</a-col> -->
<!-- <a-col :span="4"> -->
<!-- <bVideo ref="bVideoLeftRef" :videoOption="{ autoPlay: true }" :videoKey="'left-'+currentItem?.child?.学生定位?.id"/> -->
<!-- </a-col> -->
<!-- </a-row> -->
<div>
<video id="mainVideo" v-bind="videoOption" style="width:100%" @click.prevent.stop></video>
</div>
<div style="display: flex;flex-direction: row;flex-wrap: nowrap;overflow-x: scroll;">
<div v-for="(item,index) of calcOtherVideo()" class="videoMax">
<a-card :title="item?.xm" style="width: 300px" class="videoCardMain">
<bVideo :ref="el=> bVideoRefs[index]=el" :videoOption="{ autoPlay: true, onClick: bVideoClick }" :videoKey="'other-'+item.id"/>
</a-card>
</div>
</div>
2023-04-21 00:41:02 +08:00
</a-col>
</a-row>
</div>
<!-- <a-layout>
<a-layout-sider width="200" style="background: #fff">
<a-menu
v-model:openKeys="openKeys"
v-model:selectedKeys="selectedKeys"
:style="{ height: '100%', borderRight: 0 }"
mode="inline"
>
<a-menu-item v-for="(item, index) of leftList" :key="index" @click="(e) => titleClick(e,item)" :title="`${item.xq}-${item.jsmc}-${item.xm}`">
{{ item.xq }}-{{ item.jsmc }}-{{ item.xm }}
</a-menu-item>
</a-menu>
</a-layout-sider>
<a-layout>
<a-layout-content> -->
<!-- {{ currentItem }} -->
<!-- <bVideo ref="bVideoMainRef" :videoOption="{ autoPlay: true }" :videoKey="'main'+currentItem.id"/> -->
<!-- <a-row>
<a-col :span="12">
<bVideo ref="bVideoMainRef" :videoOption="{ autoPlay: true }" :videoKey="'main'+currentItem.id"/>
</a-col>
<a-col :span="12">
<bVideo ref="bVideoLeftRef" :videoOption="{ autoPlay: true }" :videoKey="'main2'+currentItem.id"/>
</a-col>
</a-row> -->
<!-- </a-layout-content>
</a-layout> -->
<!-- </a-layout> -->
</template>
<script lang="ts" setup name="zhihuijiaoshiIndexPage">
import type { MenuProps } from 'ant-design-vue';
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";
2023-04-22 15:16:05 +08:00
import { ref, onMounted, onBeforeUnmount, reactive, computed, VideoHTMLAttributes } from 'vue';
2023-04-21 00:41:02 +08:00
import bVideo from '/@/views/site/common/webRTC/video.vue';
2023-04-22 15:16:05 +08:00
import { nextTick } from 'vue';
2023-04-21 00:41:02 +08:00
2023-04-22 15:16:05 +08:00
const bVideoRefs = <any>ref([]);
2023-04-21 00:41:02 +08:00
const _document = window.document;
// const bVideoLeftRef = ref();
const leftList = <any>ref([]);
const currentItem = <any>ref({});
const topWidth = <any>ref('0');
2023-04-22 15:16:05 +08:00
const videoOption = reactive({
// width: '800', //播放器高度
// height: '450', //播放器高度
color: "#409eff", //主题色
title: '', //视频名称
//src: "https://go.dreamwq.com/videos/IronMan.mp4", //视频源
muted: true, //静音
playsinline: true,
webFullScreen: false,
speedRate: ["0.75", "1.0", "1.25", "1.5", "2.0"], //播放倍速
autoPlay: false, //自动播放
loop: false, //循环播放
mirror: false, //镜像画面
ligthOff: false, //关灯模式
volume: 0.3, //默认音量大小
controls: true, //是否显示控制器
});
2023-04-21 00:41:02 +08:00
onMounted(() => {
2023-04-22 15:16:05 +08:00
list({ pageSize: -1, sfyx: '0' }).then(res => {
let list = (res?.records) ?? [];
//聚合
let map = {};
list.forEach(x => {
let item = map[x.jsmc];
if(item){
item.child[x.xm] = x;
}else{
let child = {};
child[x.xm] = x;
map[x.jsmc] = {
...x,
child
};
}
});
leftList.value = Object.values(map);
2023-04-21 00:41:02 +08:00
topWidth.value = _document?.querySelector('.ant-layout .jeecg-default-layout-main > div')?.style?.height?? '0';
// console.log(_document?.querySelector('.ant-layout .jeecg-default-layout-main > div')?.style?.height?? '0')
});
});
// const topWidthCalc = computed(() => {
// return _document?.querySelector('.ant-layout .jeecg-default-layout-main > div')?.style?.height?? '0';
// });
// xxx = document.querySelector('.ant-layout .jeecg-default-layout-main > div').style.height
//
enum Api {
list = '/jiaoshi/kcZhihuijiaoshi/list',
}
/**
* 列表接口
* @param params
*/
const list = (params) => defHttp.get({ url: Api.list, params });
const selectedKeys = ref<string[]>(['1']);
const openKeys = ref<string[]>(['sub1']);
const titleClick = (e: Event, item: any) => {
console.log('titleClick ->', e, item);
currentItem.value = item;
playerVideo(item);
};
function playerVideo(item){
2023-04-22 15:16:05 +08:00
nextTick(() => {
//changshang == 奥威亚
// bVideoMainRef.value.connectFn(item.ip);
//bVideoMainRef.value.connectFn('rtsp://176.139.87.16/axis-media/media.amp','external');
// bVideoLeftRef.value.connectFn('rtsp://176.139.87.16/axis-media/media.amp','external');
//rtsp://admin:admin@10.250.116.235:8554/live
console.log('bVideoRefs ->',bVideoRefs,Object.values(bVideoRefs.value));
(Object.values(bVideoRefs.value)).forEach((x: any) => {
console.log(`🚀 ----------------------------------------------🚀`);
console.log(`🚀 ~ file: index.vue:148 ~ playerVideo ~ x:`, x);
console.log(`🚀 ----------------------------------------------🚀`);
// x.connectFn('rtsp://admin:admin@10.250.116.235:8554/live','external')
// if(Number(Number(Math.random()).toFixed(1))*10 >= 5){
// x.connectFn('rtsp://127.0.0.1:8554/video','external');
// }else{
// x.connectFn(`rtsp://${x.ip}/live`,'external')
// }
// return;
if(x.changshang == '奥威亚'){
x.connectFn(`rtsp://${x.ip}/stream/0?config.login=web`,'external')
}else if(x.changshang == '卓智'){
x.connectFn(`rtsp://${x.ip}/live`,'external')
}
});
setTimeout(() => {
switchVideoToMain();
},1000);
})
//bVideoRefs['main'].connectFn('rtsp://admin:admin@10.250.116.235:8554/live','external');
2023-04-21 00:41:02 +08:00
}
2023-04-22 15:16:05 +08:00
function calcOtherVideo() :any{
if(!currentItem.value.child) return {};
let map = {};
Object.keys(currentItem.value.child).forEach(key => {
// if(key != '录播主机' && key.indexOf('音频处理器') ==-1){
map[key] = currentItem.value.child[key];
// }
});
return map;
}
function switchVideoToMain(){
console.log(`🚀 ------------------------------------------------------------------------------------🚀`);
console.log(`🚀 ~ file: index.vue:188 ~ switchVideoToMain ~ switchVideoToMain:`);
console.log(`🚀 ------------------------------------------------------------------------------------🚀`);
nextTick(() => {
let mainVideo = <HTMLVideoElement> document.querySelector('#mainVideo');
let firstVideo = <HTMLVideoElement> document.querySelector('.videoMax video');
mainVideo.srcObject = firstVideo.srcObject
mainVideo.play();
});
}
function bVideoClick(e){
let mainVideo = <HTMLVideoElement> document.querySelector('#mainVideo');
let currentVideo = <HTMLVideoElement> e.srcElement;
mainVideo.srcObject = currentVideo.srcObject
mainVideo.play();
}
2023-04-21 00:41:02 +08:00
//页面销毁时销毁webRtc
onBeforeUnmount(() => {
2023-04-22 15:16:05 +08:00
bVideoRefs.value.forEach(x => {
x.closeWebRtcStreamerFn();
});
2023-04-21 00:41:02 +08:00
})
</script>
<style lang="less" scoped>
2023-04-22 15:16:05 +08:00
.videoMax{
width: 300px;
}
.videoCardMain {
:deep(.ant-card-body) {
padding: 0;
}
}
/* 隐藏video 进度条 */
video::-webkit-media-controls-timeline {
display: none;
}
2023-04-21 00:41:02 +08:00
</style>