mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-15 07:20:49 +08:00
fix: 修复随机播放模式 手动下一首不是随机的问题
This commit is contained in:
@@ -156,7 +156,20 @@ export const useMusicListHook = () => {
|
||||
state.play = true;
|
||||
return;
|
||||
}
|
||||
const playListIndex = (state.playListIndex + 1) % state.playList.length;
|
||||
|
||||
let playListIndex: number;
|
||||
|
||||
if (state.playMode === 2) {
|
||||
// 随机播放模式
|
||||
do {
|
||||
playListIndex = Math.floor(Math.random() * state.playList.length);
|
||||
} while (playListIndex === state.playListIndex && state.playList.length > 1);
|
||||
} else {
|
||||
// 列表循环模式
|
||||
playListIndex = (state.playListIndex + 1) % state.playList.length;
|
||||
}
|
||||
|
||||
state.playListIndex = playListIndex;
|
||||
await handlePlayMusic(state, state.playList[playListIndex]);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user