Created
January 5, 2017 17:31
-
-
Save verticalgrain/8efa87faff2c700d4153edd3d8523139 to your computer and use it in GitHub Desktop.
Manipulate HTML5 video at X seconds from end of video
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
| // Dynamically get the video length, and do something to a video X seconds before it ends | |
| $('.video').on('timeupdate', function(event) { | |
| var timeFromVideoEnd = 2000; | |
| var current = Math.round(event.target.currentTime * 1000); | |
| var total = Math.round(event.target.duration * 1000); | |
| if ( ( total - current ) < timeFromVideoEnd ) { | |
| $body.addClass('fade-video-out'); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment