From 71d6da4530c0b2cc584993b1f1149a38c1bfc27b Mon Sep 17 00:00:00 2001 From: dwindown Date: Sun, 4 Jan 2026 11:56:12 +0700 Subject: [PATCH] Fix "Lanjutkan" resume button to jump to saved position MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change jumpToTime to check video.seekable instead of adiloPlayer.isReady - Wait for canplay event if video is not seekable yet - This fixes issue where resume button started from 00:00 instead of saved position - Added better console logging for debugging 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- src/components/VideoPlayerWithChapters.tsx | 33 ++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/components/VideoPlayerWithChapters.tsx b/src/components/VideoPlayerWithChapters.tsx index 566a736..8d3a901 100644 --- a/src/components/VideoPlayerWithChapters.tsx +++ b/src/components/VideoPlayerWithChapters.tsx @@ -229,25 +229,36 @@ export const VideoPlayerWithChapters = forwardRef { + const jumpToTime = useCallback((time: number) => { if (isAdilo) { const video = adiloPlayer.videoRef.current; - if (video && adiloPlayer.isReady) { + + if (!video) { + console.warn('Video element not available for jump'); + return; + } + + // Try to jump immediately if video is seekable + if (video.seekable && video.seekable.length > 0) { + console.log(`🎯 Jumping to ${time}s (video seekable)`); video.currentTime = time; - const wasPlaying = !video.paused; - if (wasPlaying) { - video.play().catch((err) => { - if (err.name !== 'AbortError') { - console.error('Jump failed:', err); - } - }); - } + } else { + // Video not seekable yet, wait for it to be ready + console.log(`⏳ Video not seekable yet, waiting to jump to ${time}s`); + + const onCanPlay = () => { + console.log(`🎯 Video seekable now, jumping to ${time}s`); + video.currentTime = time; + video.removeEventListener('canplay', onCanPlay); + }; + + video.addEventListener('canplay', onCanPlay, { once: true }); } } else if (playerInstance) { playerInstance.currentTime = time; playerInstance.play(); } - }; + }, [isAdilo, adiloPlayer.videoRef, playerInstance]); const getCurrentTime = () => { return currentTime;