const handleScroll = () => { const rect = scrollSection.getBoundingClientRect() if (rect.top > 0) return // On veut 4 segments entre rect.top=0 et rect.top=-innerHeight const progress = Math.min(Math.max(-rect.top / window.innerHeight, 0), 1) const index = Math.min(Math.floor(progress * 4), 3) console.log( "rect.top:", Math.round(rect.top), "| progress:", progress.toFixed(2), "| index:", index, "| segment actuel:", currentSegment ) if (index === currentSegment) return currentSegment = index const segment = segments[index] video.currentTime = segment.start video.play() .then(() => console.log("▶️ play OK, segment", index)) .catch(e => console.log("❌ play bloqué:", e)) const checkTime = () => { if (video.currentTime >= segment.end) { video.pause() video.removeEventListener("timeupdate", checkTime) } } video.addEventListener("timeupdate", checkTime) }