diff --git a/pages/plugins/live/pull/components/h5-hls-video/h5-hls-video.vue b/pages/plugins/live/pull/components/h5-hls-video/h5-hls-video.vue index f73a06c7..76795cb0 100644 --- a/pages/plugins/live/pull/components/h5-hls-video/h5-hls-video.vue +++ b/pages/plugins/live/pull/components/h5-hls-video/h5-hls-video.vue @@ -383,16 +383,14 @@ } }) this.hlsPlayer.on(hlsjs.Events.ERROR, (event, data) => { - console.error('HLS Error:', data, event, '444') + // hls 视频加载错误 + this.$ownerInstance.callMethod('eventEmit', { + event: 'hlsError', + data + }) // 如果HLS播放失败,尝试直接播放源地址作为降级方案 if (this.videoEl && data.fatal) { this.videoEl.src = src - } else { - // hls 视频加载错误 - this.$ownerInstance.callMethod('eventEmit', { - event: 'hlsError', - data - }) } }) } else { diff --git a/pages/plugins/live/pull/components/live-content/live-content.vue b/pages/plugins/live/pull/components/live-content/live-content.vue index 05b90edb..8f75484e 100644 --- a/pages/plugins/live/pull/components/live-content/live-content.vue +++ b/pages/plugins/live/pull/components/live-content/live-content.vue @@ -340,6 +340,8 @@ // 清理socket连接 this.clear_interval_task(); this.unbind_keyboard_listener(); + // 关闭socket连接 + this.socket_close(); // 如果定时器存在,清除它 if (this.countdownTimer) { clearInterval(this.countdownTimer); @@ -506,7 +508,6 @@ this.socket_message_back_handle(res); }); this.task.onClose((res) => { - this.task = null; this.is_socket_error = true; // 尝试重连,最多30次 if ((this.reconnect_count + 1) < 30) { @@ -526,7 +527,7 @@ } }); this.task.onError((res) => { - this.task = null; + this.socket_close(); this.is_socket_error = false; this.reconnect_count = 0; this.socket_error_content = `连接失败点击重试`; @@ -539,6 +540,12 @@ } }); }, + socket_close() { + if (this.task != null) { + this.task.close(); + this.task = null; + } + }, /** * WebSocket消息回调处理 @@ -605,6 +612,9 @@ // 添加内容之后,需要滚动到最后 this.scroll_to_lower(); break; + case 'live-status': + this.$emit('liveStatus', data.content); + break; } }, @@ -1017,172 +1027,3 @@ } /* #endif */ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pages/plugins/live/pull/mixins/mixins.js b/pages/plugins/live/pull/mixins/mixins.js index 1c1f7d01..a2793b8b 100644 --- a/pages/plugins/live/pull/mixins/mixins.js +++ b/pages/plugins/live/pull/mixins/mixins.js @@ -24,7 +24,9 @@ export default { ], lastTapTime: 0, // 用于检测双击 lastTapPosition: { x: 0, y: 0 }, // 记录上次点击位置 - lastLikeTime: 0 // 记录上次点赞时间,用于防抖 + lastLikeTime: 0, // 记录上次点赞时间,用于防抖 + live_status: 'start', + live_end_msg: '主播暂时离开,请稍等...', } }, @@ -124,6 +126,16 @@ export default { // 如果已经暂停了就不需要处理了 if (!this.is_live_ended) { this.is_live_ended = true; + if (this.live_status == 'stop') { + this.live_end_msg = '直播已结束'; + } else if (['pause', 'resume'].includes(this.live_status)) { + this.live_end_msg = '主播暂时离开,请稍等...'; + // 直播状态为resume时,如果结束了,就需要重新请求直播间状态 + console.log(this.live_status); + if (this.live_status == 'resume') { + this.socket_live_status('resume'); + } + } } }, @@ -206,6 +218,18 @@ export default { } this.lastTapTime = currentTime; this.lastTapPosition = { x, y }; + }, + socket_live_status(status) { + console.log(status); + this.live_status = status; + // 如果是开始直播了或者继续直播了,则取消直播结束标记 + console.log(this.is_live_ended); + if (['start', 'resume'].includes(status) && this.is_live_ended) { + setTimeout(() => { + console.log('继续直播标记'); + this.is_live_ended = false; + }, 5000); + } } } } \ No newline at end of file diff --git a/pages/plugins/live/pull/pull.nvue b/pages/plugins/live/pull/pull.nvue index 6ebe0d7c..e8f7a497 100644 --- a/pages/plugins/live/pull/pull.nvue +++ b/pages/plugins/live/pull/pull.nvue @@ -1,23 +1,21 @@ @@ -56,6 +54,12 @@ .live-ended { // 添加渐变背景色 background-image: linear-gradient(to bottom,#AD18F9,#05DFC7); + position: absolute; + top: 0; + left: 0; + z-index: 10; + width: 100%; + height: 100%; } .live-ended-button { border-radius: 6px; diff --git a/pages/plugins/live/pull/pull.vue b/pages/plugins/live/pull/pull.vue index 71a79881..1c0e0442 100644 --- a/pages/plugins/live/pull/pull.vue +++ b/pages/plugins/live/pull/pull.vue @@ -1,24 +1,20 @@