fix(播放器): 修复播放队列和缓冲状态的处理逻辑
修复播放队列在到达底部时的暂停逻辑,并确保缓冲状态在播放时正确更新。调整了音频元素的自动播放逻辑,使其与播放状态同步。
This commit is contained in:
parent
a51ddcc023
commit
9d9c3a3ed5
|
@ -44,8 +44,10 @@ function setMetadata() {
|
|||
|
||||
function playNext() {
|
||||
if (playQueueStore.currentIndex === playQueueStore.list.length - 1) {
|
||||
console.log("at the bottom, pause")
|
||||
playQueueStore.currentIndex = 0
|
||||
player.value?.pause()
|
||||
playQueueStore.isPlaying = false
|
||||
} else {
|
||||
playQueueStore.currentIndex++
|
||||
player.value?.play()
|
||||
|
@ -66,9 +68,11 @@ function playPrevious() {
|
|||
<div>
|
||||
<audio
|
||||
:src="playQueueStore.list[playQueueStore.currentIndex] ? playQueueStore.list[playQueueStore.currentIndex].song.sourceUrl : ''"
|
||||
ref="playerRef" autoplay v-if="playQueueStore.list.length !== 0" @ended="playNext"
|
||||
@pause="playQueueStore.isPlaying = false" @play="playQueueStore.isPlaying = true"
|
||||
@playing="playQueueStore.isBuffering = false" @waiting="playQueueStore.isBuffering = true">
|
||||
ref="playerRef" :autoplay="playQueueStore.isPlaying" v-if="playQueueStore.list.length !== 0" @ended="playNext"
|
||||
@pause="playQueueStore.isPlaying = false" @play="playQueueStore.isPlaying = true" @playing="() => {
|
||||
playQueueStore.isBuffering = false
|
||||
setMetadata()
|
||||
}" @waiting="playQueueStore.isBuffering = true">
|
||||
</audio>
|
||||
|
||||
<div
|
||||
|
|
|
@ -48,6 +48,7 @@ function playTheAlbum() {
|
|||
playQueue.list = newPlayQueue
|
||||
playQueue.currentIndex = 0
|
||||
playQueue.isPlaying = true
|
||||
playQueue.isBuffering = true
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user