src/components/VideoPlayer/VideoPlayer.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/screen/flow/graphic/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/components/VideoPlayer/VideoPlayer.vue
@@ -4,7 +4,6 @@ <div class="playerBtn"> <el-icon class="icon" v-if="showPlay" @click="handlePlayer"><VideoPlay /></el-icon> <el-icon class="icon" v-if="showPause" @click="hanlePause"><VideoPause /></el-icon> <el-icon class="icon is-loading" v-if="showLoading"><Loading /></el-icon> </div> </div> </template> @@ -27,22 +26,22 @@ const videoRef = ref(null); const videojsb = ref(); const showPlay = ref(true); const isPlay = ref(false); const showPlay = ref(false); const showPause = ref(false); const showLoading = ref(false); let timer = null; let timerOut = null; //通知设备上传媒体流,做节流,防止过度点击 const handlePlayer = debounce(function() { showPlay.value = false; showLoading.value = true; // 获取播放地址 getVideoMedia(props.item.deviceId, props.item.channelId).then(res => { videojsb.value.play(res.data.url); isPlay.value = true; }).catch(() => { isPlay.value = false; showPlay.value = true; }).finally(() => { showLoading.value = false; }) // 挂定时任务,2分钟获取一次直播流数据,防止客户关闭页面,如果2分钟未获取,后端断开链接 if(timer) clearInterval(timer) @@ -53,22 +52,35 @@ }, 2000, true) const hanlePause = () => { isPlay.value = false; showPause.value = false; showPlay.value = true; clearInterval(timer) clearTimeout(timerOut); stopVideoMedia(props.item.deviceId, props.item.channelId).then(() => { console.log('关闭成功') }) } const handleEnter = () => { if(props.item.deviceId && props.item.channelId && !showPlay.value && !showLoading.value) { if(props.item.deviceId && props.item.channelId) { if(isPlay.value) { if(timerOut) clearTimeout(timerOut); showPause.value = true; // 延时2秒隐藏暂停按钮 timerOut = setTimeout(() => { showPause.value = false; }, 3000) } else { showPlay.value = true; } } } const handleLeave = () => { if(timerOut) clearTimeout(timerOut); showPause.value = false; showPlay.value = false; } // 实例化dom节点 @@ -87,7 +99,7 @@ // debug: true, supportDblclickFullscreen: false, operateBtns: { fullscreen: true, fullscreen: false, play: false, audio: true, recorder: false, @@ -128,6 +140,7 @@ videojsb.value.destroy(); } if(timer) clearInterval(timer) if(timerOut) clearTimeout(timerOut) }) @@ -160,8 +173,8 @@ font-size: 3rem; } } :deep(.jessibuca-controls) { background-color: transparent; .mask{ position: absolute; } } </style> src/views/screen/flow/graphic/index.vue
@@ -14,11 +14,16 @@ const userType = ref(getUserType()) const searchVal = ref('') const playerData = ref([]) const showFullScreen = ref(false) const fullIndex = ref() // 全屏弹窗 const handleFullScreen = (index) => { const dom = document.getElementById(`player${index}`) dom.requestFullscreen() fullIndex.value = index showFullScreen.value = true } const closeFullScreen = () => { showFullScreen.value = false } // 抓拍 @@ -116,7 +121,7 @@ <div class="item" v-for="(item, index) in playerData" :key="index"> <div class="title">{{ item.pointName }}</div> <div class="item-video" :id="`player${index}`"> <VideoPlayer :item="item" :autoPlay="true" /> <VideoPlayer :item="item" :autoPlay="false" /> </div> <div class="info"> <div class="info-list"> @@ -161,6 +166,47 @@ <el-button style="width: 6rem" @click="handleSnap(index)">抓拍</el-button> </div> </div> </div> </div> </div> </div> <div class="fullDialog" v-if="showFullScreen"> <VideoPlayer :item="playerData[fullIndex]" :autoPlay="true" /> <div class="closeIcon" @click="closeFullScreen"><el-icon><CircleClose /></el-icon></div> <div class="full-mask"> <div class="mask-list"> <div class="mask-item"> <div class="name">水位:</div> <div class="val"><span>{{ playerData[fullIndex].waterLevel }}</span>m</div> </div> <div class="mask-item"> <div class="name">表面流速:</div> <div class="val"><span>{{ playerData[fullIndex].flowVelocity }}</span>m/s</div> </div> <div class="mask-item"> <div class="name">水面宽度:</div> <div class="val"><span>{{ playerData[fullIndex].waterWidth }}</span>m</div> </div> <div class="mask-item"> <div class="name">平均流速:</div> <div class="val"><span>{{ playerData[fullIndex].avgVelocity }}</span>m/s</div> </div> <div class="mask-item"> <div class="name">过水面积:</div> <div class="val"><span>{{ playerData[fullIndex].waterArea }}</span>m³</div> </div> <div class="mask-item"> <div class="name">雷达流速:</div> <div class="val"><span>{{ playerData[fullIndex].radarVelocity }}</span>m/s</div> </div> <div class="mask-item"> <div class="name">实时流量:</div> <div class="val"><span>{{ playerData[fullIndex].newFlow }}</span>m³/h</div> </div> <div class="mask-item"> <div class="name">起点距:</div> <div class="val"><span>{{ playerData[fullIndex].radarDistance }}</span>m</div> </div> </div> </div> @@ -338,5 +384,43 @@ } } } .fullDialog{ position: fixed; left: 0; top: 0; z-index: 200; width: 100%; height: 100%; background-color: #000; .closeIcon{ position: absolute; right: 20px; top: 20px; color: #fff; font-size: 36px; } .full-mask{ position: absolute; left: 100px; bottom: 100px; width: 250px; height: 270px; background-color: rgba(0, 0, 0, 0.5); border-radius: 20px; .mask-list{ padding: 10px 20px; .mask-item{ display: flex; align-items: center; color: #fff; padding: 5px 0; .name{ width: 50%; } } } } } } </style>