feat: 添加音频URL过期事件监听,自动重新获取B站和网易云音乐音频URL并恢复播放

This commit is contained in:
alger
2025-03-30 12:40:39 +08:00
parent 1a440fad09
commit ee6e9d43fd
2 changed files with 98 additions and 0 deletions

View File

@@ -422,6 +422,8 @@ class AudioService {
console.log(`Retrying playback (${retryCount}/${maxRetries})...`);
setTimeout(tryPlay, 1000 * retryCount);
} else {
// 发送URL过期事件通知外部需要重新获取URL
this.emit('url_expired', this.currentTrack);
reject(new Error('音频加载失败,请尝试切换其他歌曲'));
}
},
@@ -432,6 +434,8 @@ class AudioService {
console.log(`Retrying playback (${retryCount}/${maxRetries})...`);
setTimeout(tryPlay, 1000 * retryCount);
} else {
// 发送URL过期事件通知外部需要重新获取URL
this.emit('url_expired', this.currentTrack);
reject(new Error('音频播放失败,请尝试切换其他歌曲'));
}
},