From 8561be6f266768316a7866a71d891000e758db32 Mon Sep 17 00:00:00 2001 From: luobisheng <727299681@qq.com> Date: 星期五, 09 十二月 2022 17:19:07 +0800 Subject: [PATCH] 点位管理视频加载 --- src/views/systemSetting/device/point/index.vue | 135 +++++++++++++++++++++++++------------------- 1 files changed, 76 insertions(+), 59 deletions(-) diff --git a/src/views/systemSetting/device/point/index.vue b/src/views/systemSetting/device/point/index.vue index 03fe51e..1feccd5 100644 --- a/src/views/systemSetting/device/point/index.vue +++ b/src/views/systemSetting/device/point/index.vue @@ -46,14 +46,16 @@ {{ item.name }}{{ item.community }} </div> <video - id="my-video" - :src="item.urlAddress" - class="video-js" + :id="item.id" + class="video-js vjs-default-skin" controls preload="auto" - width="210px" - height="150px" - ></video> + width="300px" + height="300px" + type="video/mp4" + :src="item.urlAddress" + > + </video> </div> </el-main> <el-footer> @@ -71,6 +73,73 @@ </el-container> </el-container> </template> +<script> +import departmentAside from "@/views/operate/fivepack/threepack/components/aside"; +import videoPoint from "@/api/system/videoPoint"; + +export default { + name: 'point', + components: { departmentAside }, + created() { + this.hls = new Hls(); + this.getVideoPointList(); + }, + data() { + return { + currentPage: 1, + totalNum: 10, + pageSize: 10, + videoData: [], + searchData: null, + hls: null + }; + }, + methods: { + async getVideoPointList(data) { + let communityId, streetId; + if (data) { + 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)); + this.setVideo(); + }, + setVideo() { + if (Hls.isSupported()) { + this.videoData.forEach(video => { + const videoPlayer = document.getElementById(video.id); + this.hls.loadSource(video.urlAddress); + this.hls.attachMedia(videoPlayer); + }) + } + }, + selectedDepartment(data) { + this.currentPage = 1; + data.parentId = data.id; + data.id = null; + this.searchData = data; + this.getVideoPointList(data); + }, + current_change(e) { + this.currentPage = e; + this.getVideoPointList(this.searchData); + }, + }, + beforeDestroy() { + this.hls = null; + } +}; +</script> <style lang="scss" scoped> .button-one { height: 40px; @@ -180,56 +249,4 @@ line-height: 30px; font-size: 14px; } -</style> -<script> -import departmentAside from "@/views/operate/fivepack/threepack/components/aside"; -import videoPoint from "@/api/system/videoPoint"; - -export default { - components: { departmentAside }, - created() { - this.getVideoPointList(); - }, - data() { - return { - currentPage: 1, - totalNum: 10, - pageSize: 10, - videoData: [], - searchData: null, - }; - }, - methods: { - getVideoPointList(data) { - let communityId, streetId; - if (data) { - communityId = data.parentId; - streetId = data.id; - } - 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)); - }, - selectedDepartment(data) { - this.currentPage = 1; - data.parentId = data.id; - data.id = null; - this.searchData = data; - this.getVideoPointList(data); - }, - current_change(e) { - this.currentPage = e; - this.getVideoPointList(this.searchData); - }, - }, -}; -</script> \ No newline at end of file +</style> \ No newline at end of file -- Gitblit v1.8.0