From 956fef1d8a7193ab0d7a03ce44c22ee8b4ff7e10 Mon Sep 17 00:00:00 2001 From: Astrian Zheng Date: Sun, 25 May 2025 00:10:23 +1000 Subject: [PATCH] =?UTF-8?q?feat(Player):=20=E6=B7=BB=E5=8A=A0=E7=BC=93?= =?UTF-8?q?=E5=86=B2=E7=8A=B6=E6=80=81=E6=8C=87=E7=A4=BA=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在播放器中添加了缓冲状态指示器,当音频缓冲时显示动画,提升用户体验 --- src/components/Player.vue | 25 +++++++++++++++++++------ src/stores/usePlayQueueStore.ts | 3 ++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/components/Player.vue b/src/components/Player.vue index 37cee9e..c9fbe4e 100644 --- a/src/components/Player.vue +++ b/src/components/Player.vue @@ -7,8 +7,8 @@ const playQueueStore = usePlayQueueStore() const player = useTemplateRef('playerRef') watch(() => playQueueStore.isPlaying, (newValue) => { - if (newValue) { - player.value?.play() + if (newValue) { + player.value?.play() setMetadata() } else { player.value?.pause() } @@ -16,6 +16,7 @@ watch(() => playQueueStore.isPlaying, (newValue) => { watch(() => playQueueStore.currentIndex, () => { setMetadata() + playQueueStore.isBuffering = true }) function artistsOrganize(list: string[]) { @@ -53,9 +54,9 @@ function playNext() { function playPrevious() { if (player.value && (player.value.currentTime ?? 0) < 5 && playQueueStore.currentIndex > 0) { - playQueueStore.currentIndex-- + playQueueStore.currentIndex-- player.value?.play() - } else { + } else { if (player.value) { player.value.currentTime = 0 } } } @@ -65,7 +66,9 @@ function playPrevious() {
- + + + + + + + +
diff --git a/src/stores/usePlayQueueStore.ts b/src/stores/usePlayQueueStore.ts index 323f50b..607e77f 100644 --- a/src/stores/usePlayQueueStore.ts +++ b/src/stores/usePlayQueueStore.ts @@ -6,6 +6,7 @@ export const usePlayQueueStore = defineStore('queue', () =>{ const currentIndex = ref(0) const isPlaying = ref(false) const queueReplaceLock = ref(false) + const isBuffering = ref(false) - return { list, currentIndex, isPlaying, queueReplaceLock } + return { list, currentIndex, isPlaying, queueReplaceLock, isBuffering } }) \ No newline at end of file