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;