From 33f504a674eb00f81908a05d008ca42102ccd204 Mon Sep 17 00:00:00 2001 From: Wenzhe Date: Fri, 6 Feb 2026 16:17:22 +0800 Subject: [PATCH] v1.3.6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1、视频播放结束后,需要鼓声前的bgm状态重置 --- components/SinglePageContainer.vue | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/components/SinglePageContainer.vue b/components/SinglePageContainer.vue index fa09685..a75dcc0 100644 --- a/components/SinglePageContainer.vue +++ b/components/SinglePageContainer.vue @@ -736,10 +736,17 @@ const handleVideoOpen = (isQianmenVideo = false) => { playerStore.setVideoPlaying(true) // 保存原始BGM状态 - // 无论是否是前门的视频,都保存鼓声播放前的BGM状态 - // 这样,无论点击哪个商圈的视频,只要播放鼓声前BGM是播放的,退出视频后都需要恢复BGM播放 - playerStore.wasMusicPlayingBeforeVideo = playerStore.wasMusicPlayingBeforeDrum - console.log('视频打开时,保存鼓声播放前的BGM状态:', playerStore.wasMusicPlayingBeforeDrum) + // 如果播放了鼓声,保存鼓声播放前的BGM状态 + // 如果没有播放鼓声,保存当前BGM状态 + if (playerStore.wasMusicPlayingBeforeDrum) { + // 播放了鼓声:使用鼓声播放前的BGM状态 + playerStore.wasMusicPlayingBeforeVideo = playerStore.wasMusicPlayingBeforeDrum + console.log('视频打开时,保存鼓声播放前的BGM状态:', playerStore.wasMusicPlayingBeforeDrum) + } else { + // 没有播放鼓声:使用当前BGM状态 + playerStore.saveMusicStateBeforeVideo() + console.log('视频打开时,保存当前BGM状态:', playerStore.isMusicPlaying) + } // 停止全局BGM播放 if (audioPlayer.value && playerStore.isMusicPlaying) { @@ -762,7 +769,7 @@ const handleVideoClose = () => { playerStore.setVideoPlaying(false) // 检查是否需要恢复BGM播放 - // 只有当鼓声播放前BGM是播放状态时,才恢复BGM播放 + // 如果视频打开前BGM是播放状态,或者鼓声播放前BGM是播放状态,都需要恢复BGM播放 const shouldResumeBGM = playerStore.restoreMusicStateAfterVideo() console.log('视频关闭时,是否应该恢复BGM播放:', shouldResumeBGM) @@ -781,7 +788,8 @@ const handleVideoClose = () => { console.log('全局BGM已恢复播放(视频已关闭)') }).catch(error => { console.error('BGM恢复播放失败(需要用户交互):', error) - // 不更新isMusicPlaying状态,保持为false + // 即使播放失败,也要标记为播放状态,确保UI正确 + playerStore.setMusicPlaying(true) }) } else { // 其他平台:同步处理 @@ -790,11 +798,16 @@ const handleVideoClose = () => { } } catch (error) { console.error('BGM恢复播放失败(需要用户交互):', error) - // 不更新isMusicPlaying状态,保持为false + // 即使播放失败,也要标记为播放状态,确保UI正确 + playerStore.setMusicPlaying(true) } } else { console.log('BGM保持暂停状态(视频已关闭)') } + + // 重置鼓声播放前的BGM状态,确保它不会一直保留着之前的状态 + playerStore.wasMusicPlayingBeforeDrum = false + console.log('视频关闭后,重置鼓声播放前的BGM状态为:', playerStore.wasMusicPlayingBeforeDrum) } // 处理webview打开事件