HTML5 video: stop playback frame-accurately at a timestamp (slide-style presenter)
Relying on the video 'timeupdate' event to pause at a section end overshoots by up to ~250 ms (it fires ~4 Hz), so playback bleeds into the next section. requestAnimationFrame loops also stop firing when the tab/window is hidden. A robust approach: run one check() from three triggers at once: video.requestVideoFrameCallback (per decoded frame), setInterval(check, 20) (keeps running when hidden), and timeupdate. In check(): if currentTime >= stopAt, pause() and set currentTime = stopAt. Stop a little before the cut (~0.3 s) so any scene fade-out is not captured. Also add a guard that pauses if playback crosses the end of the section the user started, so it never drifts into the next one on its own. Serve the file with a server that supports HTTP Range requests (e.g. npx serve). Python's http.server does not, so seeking/currentTime sets silently fail in Chrome.