diff --git a/publish/changeLog.md b/publish/changeLog.md index 700d941b..8da3a3f3 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -4,3 +4,4 @@ ### 修复 - 修复桌面歌词的 鼠标移入歌词区域时提高透明度 设置不稳定的问题(#2679, @Little100) +- 修复某些情况下可能播放没有声音的问题(#2693) diff --git a/src/renderer/plugins/player/index.ts b/src/renderer/plugins/player/index.ts index ec850a78..a1b70ce1 100644 --- a/src/renderer/plugins/player/index.ts +++ b/src/renderer/plugins/player/index.ts @@ -65,6 +65,16 @@ export const createAudio = () => { audio.autoplay = true audio.preload = 'auto' audio.crossOrigin = 'anonymous' + + // https://developer.chrome.com/blog/autoplay + audio.addEventListener('playing', () => { + if (audioContext?.state == 'suspended') { + void audioContext.resume().catch((err) => { + console.error('Resume audio context failed:', err) + throw err + }) + } + }) } const initAnalyser = () => {