Commit 3f06f803 authored by 陈冲's avatar 陈冲

fix: 音乐更好

parent 1abd0126
......@@ -40,9 +40,17 @@ function getBackgroundMusic(music: string, force: boolean = false) {
stopAllMusic();
}
backgroundMusic = new Audio(music)
backgroundMusic.loop = true
backgroundMusic.loop = false
backgroundMusic.preload = 'auto'
backgroundMusic.volume = 0.6
backgroundMusic.addEventListener('ended', () => {
if (!backgroundMusic || !backgroundMusic.src.endsWith(music)) {
return
}
backgroundMusic.pause()
backgroundMusic.currentTime = 0
backgroundMusic = null
}, { once: true })
backgroundMusic.load()
console.log('[Music] 新背景音乐创建完成:', backgroundMusic.src)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment