fix(musik): perbaiki timing dan rounding pada seek slider
- Gunakan durasi dari database sebagai acuan utama (bukan dari audio metadata) - Ganti Math.floor dengan Math.round untuk smoothing currentTime - Tambahkan validasi seek time: Math.min(Math.max(0, v), duration) - Tambahkan debug logging untuk tracking seek behavior - Hapus override duration di onLoadedMetadata untuk menghindari konflik Root cause: - Duration dari database (string 'MM:SS' → seconds) berbeda dengan audio.duration (float) - Math.floor menyebabkan lompatan kasar dan kehilangan presisi - onLoadedMetadata override duration dengan audio.duration yang tidak exact Fix: - Database duration = source of truth - Math.round untuk smoothing tanpa kehilangan presisi - Validasi bounds untuk mencegah seek negatif atau melebihi durasi Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -5,10 +5,14 @@ export function seekTo(
|
||||
) {
|
||||
if (!audioRef.current) return;
|
||||
|
||||
// Set waktu audio
|
||||
audioRef.current.currentTime = time;
|
||||
|
||||
// Update state jika provided
|
||||
if (setCurrentTime) {
|
||||
setCurrentTime(time);
|
||||
setCurrentTime(Math.round(time));
|
||||
}
|
||||
|
||||
// Debug log (bisa dihapus nanti)
|
||||
console.log('[seekTo] Seek to:', time, 'seconds');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user