修复某些情况下可能出现播放歌曲没有声音的问题 (#2693)

This commit is contained in:
lyswhut
2026-03-07 14:06:12 +08:00
parent 19eab0418a
commit 44d96264fb
2 changed files with 11 additions and 0 deletions

View File

@@ -4,3 +4,4 @@
### 修复
- 修复桌面歌词的 鼠标移入歌词区域时提高透明度 设置不稳定的问题(#2679, @Little100
- 修复某些情况下可能播放没有声音的问题(#2693

View File

@@ -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 = () => {