feat: 优化音乐播放逻辑

This commit is contained in:
alger
2026-03-04 19:53:50 +08:00
parent bb2dbc3f00
commit 36917a979d
5 changed files with 40 additions and 20 deletions
+2
View File
@@ -642,6 +642,7 @@ class AudioService {
newSound.on('loaderror', (_, error) => {
console.error('Audio load error:', error);
this.emit('loaderror', { track, error });
if (retryCount < maxRetries && !existingSound) {
// 预加载的音频通常已经 loaded,不应重试
retryCount++;
@@ -657,6 +658,7 @@ class AudioService {
newSound.on('playerror', (_, error) => {
console.error('Audio play error:', error);
this.emit('playerror', { track, error });
if (retryCount < maxRetries) {
retryCount++;
console.log(`Retrying playback (${retryCount}/${maxRetries})...`);