Created
July 24, 2020 10:39
-
-
Save Farmatique/daef40d50e90de05e09f4cf0f2d7473e to your computer and use it in GitHub Desktop.
Catch time of playing HTML5 video
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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