lots0logs
2/20/2016 - 12:04 AM

WordPress :: HTML5 Videos :: Pause on last frame

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>