WordPress :: HTML5 Videos :: Pause on last frame
This file contains 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
<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