From e19dcbcf017744b1fceb0b29f423aab9c2786e6f Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期三, 23 三月 2022 02:34:21 +0800 Subject: [PATCH] 修改wasm player 播放按钮 --- src/pages/cameraVideo/index/Video.vue | 333 +++++++++++++++++++++++++----------------------------- 1 files changed, 154 insertions(+), 179 deletions(-) diff --git a/src/pages/cameraVideo/index/Video.vue b/src/pages/cameraVideo/index/Video.vue index 1becda1..9f4f0f3 100644 --- a/src/pages/cameraVideo/index/Video.vue +++ b/src/pages/cameraVideo/index/Video.vue @@ -5,19 +5,24 @@ <div class="monitoring-video" ref="monitorVideo"> <div class="monitoring-video-guid"> <span - :class="guid === 1 ? 'iconfont icongongge1 activegongge':'iconfont icongongge1'" + :class="guid === 1 ? 'iconfont icongongge1 activegongge' : 'iconfont icongongge1'" @click="setGuid(1)" ></span> <span - :class="guid === 2 ? 'iconfont icongongge activegongge':'iconfont icongongge'" + :class="guid === 2 ? 'iconfont icongongge activegongge' : 'iconfont icongongge'" @click="setGuid(2)" ></span> <span - :class="guid === 3 ? 'iconfont icongongge2 activegongge':'iconfont icongongge2'" + :class="guid === 3 ? 'iconfont icongongge2 activegongge' : 'iconfont icongongge2'" @click="setGuid(3)" ></span> - <el-tooltip v-if="TreeDataPool.selectedNode.id" :content="`${showArea?'闅愯棌鍖哄煙':'鏌ョ湅鍖哄煙'}`" placement="bottom" popper-class="atooltip"> - <span :class="showArea?'activegongge':''" class="iconfont iconquyu" @click="toggleShowArea"></span> + <el-tooltip + v-if="TreeDataPool.selectedNode.id" + :content="`${showArea ? '闅愯棌鍖哄煙' : '鏌ョ湅鍖哄煙'}`" + placement="bottom" + popper-class="atooltip" + > + <span :class="showArea ? 'activegongge' : ''" class="iconfont iconquyu" @click="toggleShowArea"></span> </el-tooltip> <!-- <span v-if="TreeDataPool.selectedNode.id" @@ -37,10 +42,7 @@ </el-tooltip>--> </div> <div class="fixedRatioBox"> - <div - :class="guid === 1 ? 'video-main-box' : 'video-main-box-side'" - v-if="visibilityState" - > + <div :class="guid === 1 ? 'video-main-box' : 'video-main-box-side'" v-if="visibilityState"> <VideoItem v-for="(item, index) in TreeDataPool.videoArr" :key="index" @@ -65,15 +67,14 @@ <video-photo ref="photoview" @addToBase="toAdd"></video-photo> </div> </div> - </div> </template> <script> -import VideoItem from "../components/VideoItem"; -import VideoTask from "../components/VideoTask"; -import VideoPhoto from "../components/VideoPhoto"; -import { getCameraPlayList } from "@/api/trackCamera"; +import VideoItem from "../components/VideoItem" +import VideoTask from "../components/VideoTask" +import VideoPhoto from "../components/VideoPhoto" +import { getCameraPlayList } from "@/api/trackCamera" export default { name: "Video", @@ -82,7 +83,7 @@ VideoTask, VideoPhoto }, - data () { + data() { return { guid: 1, center: "", @@ -94,74 +95,62 @@ tracePubUrl: `${location.protocol === "https" ? "wss" : "ws"}://${location.host}/track`, websocket: null, visibilityState: true, - showArea: false, - }; + showArea: false + } }, - created () { - console.log("befor created") - // this.TreeDataPool.clean(); - // this.TreeDataPool.fetchTreeData(); - // this.guid = sessionStorage.guid ? Number(sessionStorage.guid) : this.guid; + created() { this.TreeDataPool.activeVideoIndex = sessionStorage.activeIndex ? Number(sessionStorage.activeIndex) - : this.TreeDataPool.activeVideoIndex; - this.getActiveIndex(); - this.TreeDataPool.readonly = true; - this.TreeDataPool.gbReadonly = true; - this.TreeDataPool.multiple = false; - - console.log("created") + : this.TreeDataPool.activeVideoIndex + this.getActiveIndex() + this.TreeDataPool.readonly = true + this.TreeDataPool.gbReadonly = true + this.TreeDataPool.multiple = false }, - mounted () { - document.addEventListener("visibilitychange", this.visibilitychange, false); + mounted() { + document.addEventListener("visibilitychange", this.visibilitychange, false) this.$nextTick(() => { - window.addEventListener("resize", this.resizeMonitorTask); + window.addEventListener("resize", this.resizeMonitorTask) //this.getRightWidth(); - this.resizeMonitorTask(); + this.resizeMonitorTask() }) - this.getCenter(); - this.blackAngWhite(); - this.VideoPhotoData.queryTagList(); - - let list = this.TreeDataPool.localVedioList.filter(i => { - return i.progress == 100; - }) - // console.log(list, '宸插畬鎴愮殑鏈湴瑙嗛', this.TreeDataPool.localVedioList) - this.TreeDataPool.localVedioList = list; + this.getCenter() + this.blackAngWhite() + this.VideoPhotoData.queryTagList() }, - beforeDestroy () { - window.removeEventListener("resize", this.getRightWidth); - this.CardList.details = []; - window.clearInterval(this.trackTimer); + beforeDestroy() { + window.removeEventListener("resize", this.getRightWidth) + this.CardList.details = [] + window.clearInterval(this.trackTimer) if (this.websocket) { - this.websocket.close(); + this.websocket.close() } }, watch: { - "TreeDataPool.videoArr": function (newArry) { - console.log('newArry', newArry) - const cameras = this.filterNodes(newArry); - this.getActiveIndex(); - this.$refs.taskview.showTasks(cameras); - this.$refs.photoview.showCapture(cameras); + "TreeDataPool.videoArr": function(newArry) { + console.log("newArry", newArry) + const cameras = this.filterNodes(newArry) + this.getActiveIndex() + this.$refs.taskview.showTasks(cameras) + this.$refs.photoview.showCapture(cameras) }, - "VideoPhotoData.selectBlacks": function (value) { - this.blackAngWhite(); + "VideoPhotoData.selectBlacks": function(value) { + this.blackAngWhite() }, - "VideoPhotoData.selectWhites": function (value) { - this.blackAngWhite(); + "VideoPhotoData.selectWhites": function(value) { + this.blackAngWhite() }, - "TreeDataPool.showTreeBox" (value) { - this.getRightWidth(); + "TreeDataPool.showTreeBox"(value) { + this.getRightWidth() } }, methods: { - handleTrack () { - this.track = !this.track; + handleTrack() { + this.track = !this.track if (!this.track) { - window.clearInterval(this.trackTimer); - this.websocket.close(); - return; + window.clearInterval(this.trackTimer) + this.websocket.close() + return } this.$notify({ @@ -175,16 +164,16 @@ if (!useWebSocket) { this.trackTimer = window.setInterval(() => { _this.tracking() - }, 5 * 1000); + }, 5 * 1000) } else { this.initTrackWebsocket() this.trackTimer = window.setInterval(() => { _this.videoItemMonitor() - }, 1 * 1000); + }, 1 * 1000) } }, - videoItemMonitor () { - this.websocket.send("ping"); + videoItemMonitor() { + this.websocket.send("ping") let cache = this.traceCache // 閬嶅巻褰撴湡鎾斁鐨勬憚鍍忔満, 鎸夌閫掑噺鎽勫儚鏈轰汉鍛樺瓨鍦ㄦ椂闂达紝涓�0鏃跺垹闄わ紝鎽勫儚鏈轰汉鍛樹负绌烘椂鍏抽棴 @@ -196,18 +185,17 @@ for (var person in cache[camera]) { cache[camera][person]-- if (cache[camera][person] < 0) { - delete (cache[camera][person]) + delete cache[camera][person] } } - } else { - delete (cache[camera]) + delete cache[camera] this.closePlayer(camera) } } }, - initTrackWebsocket () { - if (typeof (WebSocket) === "undefined") { + initTrackWebsocket() { + if (typeof WebSocket === "undefined") { alert("鎮ㄧ殑娴忚鍣ㄤ笉鏀寔socket") } else { // 瀹炰緥鍖杝ocket @@ -217,21 +205,21 @@ this.websocket.onmessage = this.recvieTrackMessage } }, - websocketonopen () { //杩炴帴寤虹珛涔嬪悗鎵цsend鏂规硶鍙戦�佹暟鎹� + websocketonopen() { + //杩炴帴寤虹珛涔嬪悗鎵цsend鏂规硶鍙戦�佹暟鎹� this.websocket.send("sub") }, - tracking () { - getCameraPlayList().then(data => { + tracking() { + getCameraPlayList().then((data) => { if (data && data.length) { - data.forEach(ins => { + data.forEach((ins) => { let newCamera = this.TreeDataPool.getCameraInfoById(ins.NewCameraId) if (!newCamera) { - console.log("鏈煡鎵惧埌鎽勫儚鏈猴細", ins.NewCameraId); + console.log("鏈煡鎵惧埌鎽勫儚鏈猴細", ins.NewCameraId) return } if (ins.IsNew) { this.newPlayerInViewBox(newCamera) - } else { this.replacePlayer(newCamera, ins.OldCameraId) } @@ -239,7 +227,7 @@ } }) }, - recvieTrackMessage (e) { + recvieTrackMessage(e) { let dataJson = JSON.parse(e.data) let cache = this.traceCache let camera = dataJson.camera @@ -265,12 +253,12 @@ // 鎵惧埌涓婁竴涓憚鍍忔満, 鍒ゆ柇鎽勫儚鏈洪噷鏄惁杩樻湁鍏朵粬浜�, 鏈�:鏂板紑鎾斁鍣� 娌℃湁:鍒囨崲 console.log("last camera:", cam, Object.keys(cache[cam]).length) if (Object.keys(cache[cam]).length > 2) { - delete (cache[cam][person]) + delete cache[cam][person] this.newPlayerInViewBox(camera) return } else { this.replacePlayer(camera, cam) - delete (cache[cam]) + delete cache[cam] return } } @@ -279,19 +267,16 @@ // 鏈彂鐜版挱鏀捐褰� this.newPlayerInViewBox(camera) }, - newPlayerInViewBox (id) { + newPlayerInViewBox(id) { // 鏂板鎾斁绐楀彛 let camera = this.TreeDataPool.getCameraInfoById(id) - let emptyIndex = -1; - let exist = false; + let emptyIndex = -1 + let exist = false for (let i = 0; i < this.TreeDataPool.videoArr.length; i++) { // eslint-disable-next-line - if ( - this.TreeDataPool.videoArr[i] === "" || - this.TreeDataPool.videoArr[i] === undefined - ) { + if (this.TreeDataPool.videoArr[i] === "" || this.TreeDataPool.videoArr[i] === undefined) { if (emptyIndex === -1) { - emptyIndex = i; + emptyIndex = i } } else { if (this.TreeDataPool.videoArr[i].id === camera.id) { @@ -300,10 +285,10 @@ } } if (!exist && emptyIndex !== -1) { - this.TreeDataPool.setVideoArr(emptyIndex, camera, this); + this.TreeDataPool.setVideoArr(emptyIndex, camera, this) } }, - replacePlayer (id, oldCameraId) { + replacePlayer(id, oldCameraId) { let camera = this.TreeDataPool.getCameraInfoById(id) // console.log("update:", camera.name) // 鏇挎崲鎾斁鍣� @@ -312,9 +297,10 @@ if ( this.TreeDataPool.videoArr[i] && this.TreeDataPool.videoArr[i] !== undefined && - this.TreeDataPool.videoArr[i] !== "") { + this.TreeDataPool.videoArr[i] !== "" + ) { if (this.TreeDataPool.videoArr[i].id === oldCameraId) { - this.TreeDataPool.setVideoArr(i, camera, this); + this.TreeDataPool.setVideoArr(i, camera, this) return true } } @@ -322,102 +308,103 @@ return false }, - closePlayer (id) { + closePlayer(id) { for (let i = 0; i < this.TreeDataPool.videoArr.length; i++) { // eslint-disable-next-line if ( this.TreeDataPool.videoArr[i] && this.TreeDataPool.videoArr[i] !== undefined && - this.TreeDataPool.videoArr[i] !== "") { + this.TreeDataPool.videoArr[i] !== "" + ) { if (this.TreeDataPool.videoArr[i].id === id) { - this.TreeDataPool.setVideoArr(i, undefined, this); + this.TreeDataPool.setVideoArr(i, undefined, this) return true } } } }, - visibilitychange () { + visibilitychange() { switch (document.visibilityState) { case "hidden": - this.visibilityState = false; - break; + this.visibilityState = false + break case "visible": - this.visibilityState = true; - break; + this.visibilityState = true + break } }, - blackAngWhite () { + blackAngWhite() { if (this.VideoPhotoData.selectBlacks.length > 0) { for (let i = 0; i < this.VideoPhotoData.whiteList.length; i++) { //this.VideoPhotoData.whiteList[i].disabled = true - this.$set(this.VideoPhotoData.whiteList[i], 'disabled', true) + this.$set(this.VideoPhotoData.whiteList[i], "disabled", true) } } if (this.VideoPhotoData.selectBlacks.length == 0) { for (let i = 0; i < this.VideoPhotoData.whiteList.length; i++) { //this.VideoPhotoData.whiteList[i].disabled = false - this.$set(this.VideoPhotoData.whiteList[i], 'disabled', false) + this.$set(this.VideoPhotoData.whiteList[i], "disabled", false) } } if (this.VideoPhotoData.selectWhites.length > 0) { for (let i = 0; i < this.VideoPhotoData.blackList.length; i++) { - // this.VideoPhotoData.blackList[i].disabled = true - this.$set(this.VideoPhotoData.blackList[i], 'disabled', true) + // this.VideoPhotoData.blackList[i].disabled = true + this.$set(this.VideoPhotoData.blackList[i], "disabled", true) } } if (this.VideoPhotoData.selectWhites.length == 0) { for (let i = 0; i < this.VideoPhotoData.blackList.length; i++) { - //this.VideoPhotoData.blackList[i].disabled = false - this.$set(this.VideoPhotoData.blackList[i], 'disabled', false) + //this.VideoPhotoData.blackList[i].disabled = false + this.$set(this.VideoPhotoData.blackList[i], "disabled", false) } } }, - closeWindow (index) { - this.CardList.addBaseList.splice(index, 1); + closeWindow(index) { + this.CardList.addBaseList.splice(index, 1) }, - getVideoHeight () { - let h = this.$refs.monitorVideo.offsetHeight; - this.$refs.monitorTask.style.height = h + 'px'; + getVideoHeight() { + let h = this.$refs.monitorVideo.offsetHeight + this.$refs.monitorTask.style.height = h + "px" }, - resizeMonitorTask () { - this.getRightWidth(); - this.getVideoHeight(); + resizeMonitorTask() { + this.getRightWidth() + this.getVideoHeight() }, - getRightWidth () { - let w = this.$refs.videoRight.offsetWidth; + getRightWidth() { + let w = this.$refs.videoRight.offsetWidth // console.log("w鏄細", w,this.$refs.monitorVideo.offsetWidth); - this.$refs.monitorTask.style.width = (w - this.$refs.monitorVideo.offsetWidth - 40) + 'px' + this.$refs.monitorTask.style.width = w - this.$refs.monitorVideo.offsetWidth - 40 + "px" // console.log("鍙充晶浠诲姟鐨勫搴︼細", this.$refs.monitorTask.style.width) }, - filterNodes (selectArry) { - let nodes = []; - selectArry.forEach(i => { + filterNodes(selectArry) { + let nodes = [] + selectArry.forEach((i) => { if (i && nodes.indexOf(i.id) < 0) { - nodes.push(i.id); + nodes.push(i.id) } - }); - return nodes; + }) + return nodes }, - videoItemClick (index) { - this.TreeDataPool.activeVideoIndex = index; - this.TreeDataPool.activeForceChoose = true; + videoItemClick(index) { + this.TreeDataPool.activeVideoIndex = index + this.TreeDataPool.activeForceChoose = true }, - toAdd (item) { + toAdd(item) { this.CardList.addBaseList.push(item) }, - getCenter () { + getCenter() { this.center = { x: document.documentElement.clientWidth / 2 - 250, y: document.documentElement.clientHeight / 2 - 200 - }; + } }, - resizeWidth (w) { - this.defaultWidth = w; + resizeWidth(w) { + this.defaultWidth = w }, - resizeHeight (h) { - this.defaultHeight = h; + resizeHeight(h) { + this.defaultHeight = h }, - saveAddBase (item, index) { + saveAddBase(item, index) { if (this.VideoPhotoData.selectBlacks.length === 0 && this.VideoPhotoData.selectWhites.length === 0) { this.$notify({ title: "娉ㄦ剰", @@ -427,7 +414,7 @@ return } let res = this.VideoPhotoData.addBase(item) - res.then(data => { + res.then((data) => { console.log("then", data) if (data.success) { this.$notify({ @@ -442,77 +429,65 @@ type: "error" }) } - this.CardList.addBaseList.splice(index, 1); + this.CardList.addBaseList.splice(index, 1) this.VideoPhotoData.selectBlacks = [] this.VideoPhotoData.selectWhites = [] }) }, - getActiveIndex () { - this.TreeDataPool.videoArr.length = Math.pow(this.guid, 2); - let nullVideoIndex = ""; + getActiveIndex() { + this.TreeDataPool.videoArr.length = Math.pow(this.guid, 2) + let nullVideoIndex = "" for (let i = 0; i < this.TreeDataPool.videoArr.length; i++) { // eslint-disable-next-line - if ( - this.TreeDataPool.videoArr[i] === "" || - this.TreeDataPool.videoArr[i] === undefined - ) { - nullVideoIndex = i; + if (this.TreeDataPool.videoArr[i] === "" || this.TreeDataPool.videoArr[i] === undefined) { + nullVideoIndex = i } else { - nullVideoIndex = ""; + nullVideoIndex = "" } } if ( this.TreeDataPool.activeVideoIndex !== "" && - this.TreeDataPool.activeVideoIndex < - this.TreeDataPool.videoArr.length - 1 + this.TreeDataPool.activeVideoIndex < this.TreeDataPool.videoArr.length - 1 ) { - return this.TreeDataPool.activeVideoIndex; + return this.TreeDataPool.activeVideoIndex } else { if (nullVideoIndex === "") { - this.TreeDataPool.activeVideoIndex = - this.TreeDataPool.videoArr.length - 1; + this.TreeDataPool.activeVideoIndex = this.TreeDataPool.videoArr.length - 1 } else { - this.TreeDataPool.activeVideoIndex = nullVideoIndex; + this.TreeDataPool.activeVideoIndex = nullVideoIndex } } }, - setGuid (value) { - clearTimeout(this.trackTimer); + setGuid(value) { + clearTimeout(this.trackTimer) if (value < this.guid && this.TreeDataPool.activeVideoIndex > value) { // eslint-disable-next-line - for ( - let i = this.TreeDataPool.activeVideoIndex - 1; - i < this.TreeDataPool.videoArr.length; - i++ - ) { + for (let i = this.TreeDataPool.activeVideoIndex - 1; i < this.TreeDataPool.videoArr.length; i++) { // eslint-disable-next-line - if ( - this.TreeDataPool.videoArr[i] && - this.TreeDataPool.videoArr[i]["isPlaying"] - ) { - this.TreeDataPool.videoArr[i]["isPlaying"] = false; + if (this.TreeDataPool.videoArr[i] && this.TreeDataPool.videoArr[i]["isPlaying"]) { + this.TreeDataPool.videoArr[i]["isPlaying"] = false } } } - this.guid = value; - sessionStorage.guid = this.guid; - sessionStorage.activeIndex = this.TreeDataPool.activeVideoIndex; - this.getActiveIndex(); + this.guid = value + sessionStorage.guid = this.guid + sessionStorage.activeIndex = this.TreeDataPool.activeVideoIndex + this.getActiveIndex() }, - toggleShowArea () { - this.showArea = !this.showArea; + toggleShowArea() { + this.showArea = !this.showArea } }, - destroyed () { - window.removeEventListener("resize", this.getRightWidth); - this.CardList.details = []; - this.CardList.addBaseList = []; - this.VideoPhotoData.selectBlacks = []; - this.VideoPhotoData.selectWhites = []; + destroyed() { + window.removeEventListener("resize", this.getRightWidth) + this.CardList.details = [] + this.CardList.addBaseList = [] + this.VideoPhotoData.selectBlacks = [] + this.VideoPhotoData.selectWhites = [] //this.TreeDataPool.treeActiveName = "camera"; } -}; +} </script> <style lang="scss"> -- Gitblit v1.8.0