Forked from lots0logs/epanel-integration-body.html
Last active
April 22, 2020 17:46
-
-
Save martinbkaiser/9eb9b41c5b8a899efbc1889e79a3ac13 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(); | |
clearInterval(interval); | |
} | |
}, 450); | |
}, false); | |
}); | |
}); | |
}); | |
})(jQuery); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment