// src/player/playlist.ts
// Pure playlist index math — no DOM, no GPU. Returns the new index, wrapping
// when loop is on, or null when an end is reached and loop is off (signals the
// cycle to stop).
export function nextIndex(current: number, length: number, loop: boolean): number | null {
if (length <= 0) return null;
if (current + 1 < length) return current + 1;
return loop ? 0 : null;
}
export function prevIndex(current: number, length: number, loop: boolean): number | null {
if (length <= 0) return null;
if (current - 1 >= 0) return current - 1;
return loop ? length - 1 : null;
}