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