Skip to content

Commit 7b2f628

Browse files
committed
fix: 修复不循环模式导致无法播放
1 parent d3b6ec0 commit 7b2f628

5 files changed

Lines changed: 15 additions & 8 deletions

File tree

‎src/components/player/FullPlayer/index.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ const toggleLyric = (): void => {
448448
variant="ghost"
449449
circle
450450
:disabled="!hasTrack"
451-
@click="player.nextTrack()"
451+
@click="player.nextTrack(true)"
452452
>
453453
<template #icon><IconLucideSkipForward /></template>
454454
</SButton>

‎src/components/player/PlayerControls.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const hasTrack = computed(() => !!media.track);
7575
ripple
7676
:size="compact ? 34 : 38"
7777
:disabled="!hasTrack"
78-
@click="player.nextTrack()"
78+
@click="player.nextTrack(true)"
7979
>
8080
<template #icon><IconLucideSkipForward /></template>
8181
</SButton>

‎src/core/hotkey/registry.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const buildRegistry = (): void => {
2727
// 播放/暂停
2828
handlers.set("player.togglePlay", () => player.togglePlay());
2929
// 下一曲
30-
handlers.set("player.next", () => player.nextTrack());
30+
handlers.set("player.next", () => player.nextTrack(true));
3131
// 上一曲
3232
handlers.set("player.prev", () => player.prevTrack());
3333
// 快进

‎src/core/player/events.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export const handleEvent = async (event: PlayerEvent): Promise<void> => {
100100
await pause();
101101
break;
102102
case "next":
103-
await nextTrack();
103+
await nextTrack(true);
104104
break;
105105
case "prev":
106106
await prevTrack();

‎src/core/player/index.ts‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ export const recoverFromSourceFailure = async (): Promise<void> => {
231231
/** 恢复播放 */
232232
export const play = async (): Promise<void> => {
233233
const status = useStatusStore();
234+
if (status.state === "stopped" && status.currentTrack) {
235+
await loadTrack(status.currentTrack);
236+
return;
237+
}
234238
const prev = status.state;
235239
status.state = "playing";
236240
playback.setPlaying(true);
@@ -453,8 +457,11 @@ export const dislikeFmTrack = async (): Promise<void> => {
453457
if (next) await loadTrack(next);
454458
};
455459

456-
/** 播放下一首,队列末尾时根据循环模式决定行为 */
457-
export const nextTrack = async (): Promise<void> => {
460+
/**
461+
* 播放下一首
462+
* @param manual - 用户手动点下一曲
463+
*/
464+
export const nextTrack = async (manual = false): Promise<void> => {
458465
const status = useStatusStore();
459466
// 私人 FM
460467
if (status.fmMode) {
@@ -465,8 +472,8 @@ export const nextTrack = async (): Promise<void> => {
465472
if (queue.queueLength.value === 0) return;
466473
// 到末尾了
467474
if (status.playIndex >= queue.queueLength.value - 1) {
468-
// 列表循环 / 单曲循环:回到首位继续播放
469-
if (status.repeatMode === "list" || status.repeatMode === "one") {
475+
// 列表循环 / 单曲循环,或用户手动点下一曲
476+
if (status.repeatMode === "list" || status.repeatMode === "one" || manual) {
470477
if (status.shuffleMode === "on" && queue.queueLength.value > 1) {
471478
// 重新洗牌产生新顺序,当前歌在 index 0,从 1 开始避免重复
472479
queue.shuffleQueue(status.playIndex);

0 commit comments

Comments
 (0)