- Integrate togglePlayPause, getNextIndex, getPrevIndex, handleRepeatOrNext, seekTo, toggleShuffle, setAudioVolume, toggleMute library functions - Fix ESLint warnings: remove unused eslint-disable, add missing useEffect dependencies - Fix ESLint error in useMusicPlayer.ts togglePlayPause function - Add force-dynamic export to root layout to prevent prerendering errors - Improve seek slider with preview/commit functionality - Add isSeeking state to prevent UI flickering during seek Fixes: Build PageNotFoundError for admin/darmasaba pages Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
32 lines
613 B
TypeScript
32 lines
613 B
TypeScript
export function getNextIndex(
|
|
currentIndex: number,
|
|
total: number,
|
|
isShuffle: boolean
|
|
) {
|
|
if (total === 0) return -1;
|
|
|
|
if (isShuffle) {
|
|
return Math.floor(Math.random() * total);
|
|
}
|
|
|
|
return (currentIndex + 1) % total;
|
|
}
|
|
|
|
export function getPrevIndex(
|
|
currentIndex: number,
|
|
total: number,
|
|
isShuffle: boolean
|
|
) {
|
|
if (total === 0) return -1;
|
|
|
|
if (isShuffle) {
|
|
return Math.floor(Math.random() * total);
|
|
}
|
|
|
|
return currentIndex - 1 < 0 ? total - 1 : currentIndex - 1;
|
|
}
|
|
|
|
//pakai di ui
|
|
|
|
// const next = getNextIndex(currentSongIndex, filteredMusik.length, isShuffle);
|
|
// playSong(next);
|