Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Farmatique/daef40d50e90de05e09f4cf0f2d7473e to your computer and use it in GitHub Desktop.
Save Farmatique/daef40d50e90de05e09f4cf0f2d7473e to your computer and use it in GitHub Desktop.
Catch time of playing HTML5 video
//https://stackoverflow.com/questions/53921097/html5-video-pause-for-a-few-seconds-then-continue-playback
<video id="video" playsinline muted loop controls autoplay width='300'>
<source src="https://html5demos.com/assets/dizzy.mp4" type="video/mp4"/>
</video>
var video = document.getElementById('video');
video.addEventListener("timeupdate", tick);
function tick(e) {
var t = this.currentTime;
if (t >= 3) {
this.pause();
video.removeEventListener("timeupdate", tick);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment