Created
June 26, 2014 00:44
-
-
Save robflaherty/02acf83028f8f432f48c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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