You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
duoji-frontend/src/views/realTimeMonitoring/index.vue

143 lines
4.2 KiB
Vue

6 years ago
<template>
<div class="realTime bg-white">
4 years ago
<a-tabs default-active-key="1" slot="headerContent" v-model="tabKey" @change="tabsChange" padding:10px>
4 years ago
<a-tab-pane :key="item.streetId.toString()" :tab="item.streetName" v-for="item in realTimeListData"></a-tab-pane>
</a-tabs>
4 years ago
<!-- {{cameras.length}} {{ selectTab.videoStyleRow }} * {{ selectTab.videoStyleColumn }}-->
<a-row :gutter="20">
<a-col
v-for="(item, index) in cameras.slice(0, selectTab.videoStyleRow * selectTab.videoStyleColumn)"
:span="24 / selectTab.videoStyleColumn"
:key="index"
:style="{
height: videoHeight,
4 years ago
4 years ago
marginBottom: ((selectTab.videoStyleRow * selectTab.videoStyleColumn - index - 1) >= selectTab.videoStyleColumn) ? '20px': 0
}"
>
4 years ago
<video
:style="{
height: videoHeight,
}"
4 years ago
4 years ago
:id="`camera${item.id}`"
4 years ago
autoplay muted ></video>
4 years ago
</a-col>
</a-row>
</div>
6 years ago
</template>
6 years ago
<script>
4 years ago
import WebRtcPlayer from "../../../public/static/webrtcplayer"
6 years ago
export default {
4 years ago
name: "realTimeMonitoring",
4 years ago
components: {
4 years ago
//VideoPlayer
4 years ago
},
data() {
return {
realTimeListData: [],
url: "722e6f04-bb3c-34b1-bcc7-ae9f6cd72e68",
tabKey: "0",
path: [],
player: "",
visible: false,
4 years ago
modelData: [],
clientHeight: 0,
4 years ago
4 years ago
players: []
};
},
4 years ago
computed: {
selectTab() {
return (this.realTimeListData.filter(item=> item.streetId == this.tabKey)[0] || {})
},
cameras() {
return this.selectTab.cameras || [];
},
videoHeight() {
4 years ago
return (( this.clientHeight)/ this.selectTab.videoStyleRow ) + 'px'
4 years ago
},
},
4 years ago
//inject: ['reload'],
mounted() {
4 years ago
this.getClientHeight()
this.getRealTimeList()
4 years ago
4 years ago
this.tabKey = sessionStorage.getItem('tabKey');
4 years ago
},
4 years ago
destroyed() {
4 years ago
this.destory()
},
methods: {
4 years ago
getClientHeight() {
this.clientHeight = this.$el.clientHeight - 80;
},
getRealTimeList(){
4 years ago
this.$api.httpApi.getRealTimeList({
data: {}
}).then(res => {
if(res.code == 200) {
4 years ago
this.realTimeListData = res.data.reverse();
4 years ago
if (sessionStorage.getItem('tabKey') == null) {
console.log("tabKey"+this.realTimeListData[0].id)
sessionStorage.setItem('tabKey', this.realTimeListData[0].streetId)
this.tabKey = sessionStorage.getItem('tabKey');
}
4 years ago
this.$nextTick(() => {
this.autoPlay()
})
}
4 years ago
}).catch(err => {
console.log(err)
})
},
4 years ago
5 years ago
tabsChange(key) {
sessionStorage.setItem('tabKey', key)
4 years ago
this.destory()
4 years ago
this.$nextTick(() => {
this.autoPlay()
})
},
4 years ago
4 years ago
autoPlay(){
4 years ago
this.players = []
4 years ago
for(var a of this.realTimeListData){
for (let b of a.cameras){
4 years ago
let video = document.getElementById('camera'+b.id);
4 years ago
if(video){
4 years ago
console.log("play:"+b.id)
let server = b.rtcServer+":"+b.rtcServerPort;
let player = new WebRtcPlayer(server,video,'camera'+b.id);
4 years ago
//player.play('camera'+b.id);
4 years ago
this.players.push(player)
4 years ago
}
4 years ago
}
}
4 years ago
},
4 years ago
destory(){
for(let player of this.players){
console.log("stop")
player.destroy()
}
4 years ago
}
},
6 years ago
};
</script>
4 years ago
<style lang='scss' scoped>
.realTime {
4 years ago
padding: 10px;
}
</style>