From 15c5e70dd90a0389d70b3d855977dfd9070588fc Mon Sep 17 00:00:00 2001 From: web <candymxq888@outlook.com> Date: 星期二, 03 六月 2025 09:48:55 +0800 Subject: [PATCH] fix:修改金川视频播放,弹窗方式 --- src/components/VideoPlayer/VideoPlayer.vue | 53 ++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/components/VideoPlayer/VideoPlayer.vue b/src/components/VideoPlayer/VideoPlayer.vue index ee5f2a8..82e1f2d 100644 --- a/src/components/VideoPlayer/VideoPlayer.vue +++ b/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(!showPlay.value && !showLoading.value) { - showPause.value = true; + 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,15 +99,22 @@ // debug: true, supportDblclickFullscreen: false, operateBtns: { - fullscreen: true, + fullscreen: false, play: false, audio: true, recorder: false, }, - controlAutoHide: true, - forceNoOffscreen: true, + controlAutoHide: false, + forceNoOffscreen: false, + hasAudio: false, + heartTimeout: 5, + heartTimeoutReplay:true, + heartTimeoutReplayTimes: 3, + hiddenAutoPause: false, isNotMute: false, - heartTimeoutReplay:false, + hotKey: true, + isFlv: false, + recordType: "mp4", }) ); } @@ -106,6 +125,9 @@ // 自动播放 if(props.autoPlay && props.item.deviceId && props.item.channelId) { handlePlayer() + } + if(!props.item.deviceId || !props.item.channelId) { + showPlay.value = false; } }; @@ -118,6 +140,7 @@ videojsb.value.destroy(); } if(timer) clearInterval(timer) + if(timerOut) clearTimeout(timerOut) }) @@ -150,8 +173,8 @@ font-size: 3rem; } } - :deep(.jessibuca-controls) { - background-color: transparent; - } + .mask{ + position: absolute; + } } </style> -- Gitblit v1.9.3