From a47e01d71ce4d416f8fd50e2ae16228d115b4104 Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期二, 13 十二月 2022 14:56:57 +0800 Subject: [PATCH] 视频显示修改 --- src/views/systemSetting/device/point/index.vue | 119 ++++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 72 insertions(+), 47 deletions(-) diff --git a/src/views/systemSetting/device/point/index.vue b/src/views/systemSetting/device/point/index.vue index 924bbde..9093623 100644 --- a/src/views/systemSetting/device/point/index.vue +++ b/src/views/systemSetting/device/point/index.vue @@ -24,39 +24,26 @@ ></div> </el-header> - <el-main style="display: flex; flex-wrap: wrap; overflow-y: scroll"> + <el-main class="video-main"> <div v-for="item in videoData" - style=" - width: 240px; - position: relative; - margin-left: 20px; - " + :key="item.id" + style="position: relative" > - <div - style=" - color: rgb(75, 155, 183); - font-size: 11px; - line-height: 18px; - position: absolute; - z-index: 1; - left: 50px; - " - > - {{ item.name }}{{ item.community }} - </div> + <div class="video-title">{{ item.name }}{{ item.community }}</div> + <video :id="item.id" - class="video-js vjs-default-skin" + class="video-js" controls preload="auto" - width="240px" - height="200px" + width="400px" + height="300px" type="video/mp4" - :src="item.urlAddress" - > - </video> - <div @click="loadVideo(item)" class="button-div">鏌ョ湅瑙嗛</div> + ></video> + <div class="button-div"> + <div @click="loadVideo(item)">鏌ョ湅瑙嗛</div> + </div> </div> </el-main> <el-footer> @@ -79,9 +66,9 @@ import videoPoint from "@/api/system/videoPoint"; export default { - name: 'point', + name: "point", components: { departmentAside }, - created() { + created() { this.hls = new Hls(); this.getVideoPointList(); }, @@ -89,10 +76,11 @@ return { currentPage: 1, totalNum: 10, - pageSize: 10, + pageSize: 8, videoData: [], searchData: null, - hls: null + hls: null, + videoList:[] }; }, methods: { @@ -102,23 +90,43 @@ communityId = data.parentId; streetId = data.id; } - await videoPoint.getVideoPointList({ - current: this.currentPage, - size: this.pageSize, - communityId, - streetId, - }) - .then(({ records, total }) => { - this.videoData = records; - this.totalNum = total; - }) - .catch((err) => this.$message.error(err)); + await videoPoint + .getVideoPointList({ + current: this.currentPage, + size: this.pageSize, + communityId, + streetId, + }) + .then(({ records, total }) => { + this.videoData = records; + this.totalNum = total; + }) + .catch((err) => this.$message.error(err)); }, - loadVideo(data) { + loadVideo(item) { if (Hls.isSupported()) { - const videoPlayer = document.getElementById(data.id); - this.hls.loadSource(data.urlAddress); - this.hls.attachMedia(videoPlayer); + var video = document.getElementById(item.id); + var hls = new Hls(); + videoPoint.getVideoPointUrl(item.platResourceId).then((res) => { + if (res.code === 0) { + hls.loadSource(res.data); + hls.attachMedia(video); + this.videoList.push(video); + // hls.on(Hls.Events.MANIFEST_PARSED, function () { + // // video.play(); + // document.body.addEventListener( + // "click", + // function () { + // video.play(); + // }, + // false + // ); + // }); + setTimeout(() => { + video.play(); + }, 2000); + } + }); } }, selectedDepartment(data) { @@ -133,9 +141,11 @@ this.getVideoPointList(this.searchData); }, }, - beforeDestroy() { - this.hls = null; - } + beforeDestroy(){ + videoList.forEach(element => { + element.push() + }); + }, }; </script> <style lang="scss" scoped> @@ -197,7 +207,21 @@ margin-left: 90px; cursor: pointer; } +.video-main { + display: flex; + flex-wrap: wrap; + overflow-y: scroll; + margin-left: 20px; +} +.video-title { + color: rgb(75, 155, 183); + font-size: 11px; + line-height: 18px; + position: absolute; + z-index: 1; + left: 50px; +} .button-div { color: rgb(75, 155, 183); position: absolute; @@ -206,6 +230,7 @@ width: 100%; margin-left: 20px; cursor: pointer; + width: calc(100% - 20px); border: 1px solid rgb(75, 155, 183); } -- Gitblit v1.8.0