| | |
| | | <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> |
| | |
| | | |
| | | 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) |
| | |
| | | }, 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) { |
| | | 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节点 |
| | |
| | | // debug: true, |
| | | supportDblclickFullscreen: false, |
| | | operateBtns: { |
| | | fullscreen: true, |
| | | fullscreen: false, |
| | | play: false, |
| | | audio: true, |
| | | recorder: false, |
| | |
| | | videojsb.value.destroy(); |
| | | } |
| | | if(timer) clearInterval(timer) |
| | | if(timerOut) clearTimeout(timerOut) |
| | | }) |
| | | |
| | | |
| | |
| | | font-size: 3rem; |
| | | } |
| | | } |
| | | :deep(.jessibuca-controls) { |
| | | background-color: transparent; |
| | | } |
| | | .mask{ |
| | | position: absolute; |
| | | } |
| | | } |
| | | </style> |