Created
February 20, 2016 00:04
-
-
Save lots0logs/c8d1d4eaf24ffd8990ca to your computer and use it in GitHub Desktop.
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