diff --git a/src/app/darmasaba/(pages)/musik/lib/seek.ts b/src/app/darmasaba/(pages)/musik/lib/seek.ts index 68338f23..69b4b015 100644 --- a/src/app/darmasaba/(pages)/musik/lib/seek.ts +++ b/src/app/darmasaba/(pages)/musik/lib/seek.ts @@ -3,16 +3,23 @@ export function seekTo( time: number, setCurrentTime?: (v: number) => void ) { - if (!audioRef.current) return; + if (!audioRef.current) { + console.error('[seekTo] Audio element tidak ada!'); + return; + } + + console.log('[seekTo] Before seek - currentTime:', audioRef.current.currentTime, 'Target:', time); // Set waktu audio audioRef.current.currentTime = time; + console.log('[seekTo] After seek - currentTime:', audioRef.current.currentTime); + // Update state jika provided if (setCurrentTime) { setCurrentTime(Math.round(time)); } - // Debug log (bisa dihapus nanti) + // Debug log console.log('[seekTo] Seek to:', time, 'seconds'); } diff --git a/src/app/darmasaba/(pages)/musik/musik-desa/page.tsx b/src/app/darmasaba/(pages)/musik/musik-desa/page.tsx index 76e629ce..47ac6027 100644 --- a/src/app/darmasaba/(pages)/musik/musik-desa/page.tsx +++ b/src/app/darmasaba/(pages)/musik/musik-desa/page.tsx @@ -103,6 +103,7 @@ const MusicPlayer = () => { // Update duration when song changes useEffect(() => { if (currentSong && audioRef.current) { + console.log('[useEffect Song Change] currentSong:', currentSong.judul, 'Index:', currentSongIndex); // Gunakan durasi dari database sebagai acuan utama const durationParts = currentSong.durasi.split(':'); const durationInSeconds = parseInt(durationParts[0]) * 60 + parseInt(durationParts[1]); @@ -161,6 +162,7 @@ const MusicPlayer = () => { const skipBack = () => { const prevIndex = getPrevIndex(currentSongIndex, filteredMusik.length, isShuffle); if (prevIndex >= 0) { + console.log('[skipBack] Changing song to index:', prevIndex); playSong(prevIndex); } }; @@ -168,6 +170,7 @@ const MusicPlayer = () => { const skipForward = () => { const nextIndex = getNextIndex(currentSongIndex, filteredMusik.length, isShuffle); if (nextIndex >= 0) { + console.log('[skipForward] Changing song to index:', nextIndex); playSong(nextIndex); } }; @@ -193,13 +196,15 @@ const MusicPlayer = () => { return ( - {/* Hidden audio element */} + {/* Hidden audio element - gunakan key yang stabil untuk mencegah remount */} {currentSong?.audioFile && (