Fix "Lanjutkan" resume button to jump to saved position

- 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 <noreply@anthropic.com>
This commit is contained in:
dwindown
2026-01-04 11:56:12 +07:00
parent 8fc31b402d
commit 71d6da4530

View File

@@ -229,25 +229,36 @@ export const VideoPlayerWithChapters = forwardRef<VideoPlayerRef, VideoPlayerWit
}, [isYouTube, findCurrentChapter, onChapterChange, onTimeUpdate, chapters, saveProgressDebounced]); }, [isYouTube, findCurrentChapter, onChapterChange, onTimeUpdate, chapters, saveProgressDebounced]);
// Jump to specific time using Plyr API or Adilo player // Jump to specific time using Plyr API or Adilo player
const jumpToTime = (time: number) => { const jumpToTime = useCallback((time: number) => {
if (isAdilo) { if (isAdilo) {
const video = adiloPlayer.videoRef.current; 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; video.currentTime = time;
const wasPlaying = !video.paused; } else {
if (wasPlaying) { // Video not seekable yet, wait for it to be ready
video.play().catch((err) => { console.log(`⏳ Video not seekable yet, waiting to jump to ${time}s`);
if (err.name !== 'AbortError') {
console.error('Jump failed:', err); 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) { } else if (playerInstance) {
playerInstance.currentTime = time; playerInstance.currentTime = time;
playerInstance.play(); playerInstance.play();
} }
}; }, [isAdilo, adiloPlayer.videoRef, playerInstance]);
const getCurrentTime = () => { const getCurrentTime = () => {
return currentTime; return currentTime;