Notes slider musik belum berfungsi

This commit is contained in:
2026-03-02 14:28:20 +08:00
parent 91e32f3f1c
commit ae3187804e
3 changed files with 329 additions and 48 deletions

View File

@@ -1,15 +1,19 @@
export function seekTo(
audioRef: React.RefObject<HTMLAudioElement | null>,
audioRef: React.RefObject<HTMLAudioElement>,
time: number,
setCurrentTime?: (v: number) => void
) {
if (!audioRef.current) return;
// Validasi: jangan seek melebihi durasi atau negatif
const duration = audioRef.current.duration || 0;
const safeTime = Math.min(Math.max(0, time), duration);
// Set waktu audio
audioRef.current.currentTime = time;
audioRef.current.currentTime = safeTime;
// Update state jika provided
if (setCurrentTime) {
setCurrentTime(Math.round(time));
setCurrentTime(Math.floor(safeTime));
}
}