Skip to content

Commit a119e01

Browse files
refactor(backlog): unconditionally pause all backlog audios
移除 'audio.id !== currentAudioId' 排除判断。后续逻辑会 重置并播放当前音频(currentTime = 0 + play()),故前置 pause 不需要排除当前。简化代码,无功能差异。 反馈来源:PR review
1 parent 940c2cf commit a119e01

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

packages/webgal/src/UI/Backlog/Backlog.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,12 @@ export const Backlog = () => {
127127
<div
128128
onClick={() => {
129129
playSeClick();
130-
// 暂停其他所有正在播放的 backlog 语音,避免多条音频混合
131-
const currentAudioId = 'backlog_audio_play_element_' + indexOfBacklog;
130+
// 暂停所有 backlog 语音(包括当前;后续会重置并播放当前)
132131
document
133132
.querySelectorAll('[id^="backlog_audio_play_element_"]')
134133
.forEach((audio: any) => {
135-
if (audio.id !== currentAudioId) {
136-
audio.pause();
137-
audio.currentTime = 0;
138-
}
134+
audio.pause();
135+
audio.currentTime = 0;
139136
});
140137
// 暂停游戏内正在播放的语音,避免与 backlog 语音混合
141138
const currentVocal = document.getElementById('currentVocal') as HTMLAudioElement | null;
@@ -146,7 +143,9 @@ export const Backlog = () => {
146143
// 卸载 vocal-play perform,避免其 blockingAuto 阻塞自动播放
147144
WebGAL.gameplay.performController.unmountPerform('vocal-play', true);
148145
// 获取到播放 backlog 语音的元素
149-
const backlog_audio_element: any = document.getElementById(currentAudioId);
146+
const backlog_audio_element: any = document.getElementById(
147+
'backlog_audio_play_element_' + indexOfBacklog,
148+
);
150149
if (backlog_audio_element) {
151150
backlog_audio_element.currentTime = 0;
152151
const userDataStore = webgalStore.getState().userData;

0 commit comments

Comments
 (0)