Skip to content

Instantly share code, notes, and snippets.

@lots0logs
Created February 20, 2016 00:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lots0logs/c8d1d4eaf24ffd8990ca to your computer and use it in GitHub Desktop.
Save lots0logs/c8d1d4eaf24ffd8990ca to your computer and use it in GitHub Desktop.
WordPress :: HTML5 Videos :: Pause on last frame
<script>
(function($) {
$(document).ready(function() {
var $videos = $('.play_once video');
$videos.each(function() {
var $video = $(this)[0];
$video.removeAttr('loop');
$video.addEventListener('loadedmetadata', function() {
var pause_at = $video.duration - 0.5,
interval;
$video.addEventListener('playing', function() {
interval = setInterval(function() {
if ($video.currentTime >= pause_at) {
$video.pause();
}
}, 450);
}, false);
});
});
});
})(jQuery);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment