Skip to content

Instantly share code, notes, and snippets.

@stugoo
Created July 21, 2013 14:48
Show Gist options
  • Select an option

  • Save stugoo/6048765 to your computer and use it in GitHub Desktop.

Select an option

Save stugoo/6048765 to your computer and use it in GitHub Desktop.
Video-js player autoplay then pause at a certain time
var video = function() {
if( $('#video').length > 0 ){
videojs("video", {}, function(){
playvideo(this);
});
}
};
playvideo = function(theVideo) {
var pauseTime = 9,
current,
getToPlay = function(){
current = Math.floor(this.currentTime());
if (current == pauseTime) {
this.pause();
theVideo.off("timeupdate", getToPlay);
}
};
theVideo.on("timeupdate", getToPlay);
theVideo.play();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment