added loop

This commit is contained in:
Patryk Koreń
2026-02-12 17:51:08 +01:00
parent f9f0ba9b1f
commit 20a36703e6
4 changed files with 50 additions and 6 deletions

View File

@@ -7,7 +7,14 @@ import { add_to_history } from "./util/history";
const queue: Queue = {
songList: [],
current: null
current: null,
loop: null,
}
export function toggleLoop(): AudioFile | null {
if (queue.loop) queue.loop = null
else queue.loop = queue.current
return queue.loop
}
export async function requestSong(
@@ -36,7 +43,7 @@ export async function forceRequestSong(
export async function updatePlayer() {
if (player.state.status === AudioPlayerStatus.Idle) {
const nextSong = queue.songList.shift()
const nextSong = queue.loop ?? queue.songList.shift()
if (!nextSong) {
queue.current = null
return