Created
July 21, 2013 14:48
-
-
Save stugoo/6048765 to your computer and use it in GitHub Desktop.
Video-js player autoplay then pause at a certain time
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 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