Skip to content

Instantly share code, notes, and snippets.

@robflaherty
Created June 26, 2014 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robflaherty/02acf83028f8f432f48c to your computer and use it in GitHub Desktop.
Save robflaherty/02acf83028f8f432f48c to your computer and use it in GitHub Desktop.
var videoPlaying;
var v = document.getElementsByTagName("video")[0];
// When the video starts
v.addEventListener('playing', function() {
// Poll the video every 5 seconds and keep the Riveted timer going
videoPlaying = setInterval(function() {
if (!v.paused) {
riveted.trigger();
}
}, 5000);
}, true);
// Stop polling when the video is paused
v.addEventListener('pause', function() {
clearTimeout(videoPlaying);
}, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment