Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinbkaiser/9eb9b41c5b8a899efbc1889e79a3ac13 to your computer and use it in GitHub Desktop.
Save martinbkaiser/9eb9b41c5b8a899efbc1889e79a3ac13 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();
clearInterval(interval);
}
}, 450);
}, false);
});
});
});
})(jQuery);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment