I would like my MP4 video on the homepage to end and stop on the last frame, but right now it jumps back to the beginning and stops on the first frame. Single play, no repeat. I’m using a mac, tested on Safari, Firefox and Chrome – it appears on all of them. I was asked if I removed the Pause snippet, and I did not remove any snippets.
Hey ellephillips,
Thank you for the inquiry.
We cannot find the pause snippet or script in the document. Did you add this snippet in the functions.php file?
add_action('wp_footer', 'ava_custom_script', 10);
function ava_custom_script(){
?>
<script>
(function($){
var video = document.getElementsByTagName('video')[0];
video.addEventListener("timeupdate", function() {
if (video.currentTime >= 8) {
video.pause();
console.log('paused');
}}, false);
}(jQuery));
</script>
<?php
}
This should pause the video exactly after 8 seconds.
Related thread: https://kriesi.at/support/topic/problem-with-looping-video/#post-441912
Best regards,
Ismael
I tried adding your code above but it brought back errors in my functions.php file. So I went to the related thread and tried that code (changing it from 8 seconds to 20 seconds), and it worked perfectly. Thank you for getting back to me with this resolution.
add_action(‘wp_footer’, ‘ava_custom_script’, 10);
function ava_custom_script(){
?>
<script>
(function($){
var video = document.getElementsByTagName(‘video’)[0];
video.addEventListener(“timeupdate”, function() {
if (video.currentTime >= 20) {
video.pause();
console.log(‘paused’);
}}, false);
}(jQuery));
</script>
<?php
}
Hi,
Did you need additional help with this topic or shall we close?
Best regards,
Jordan Shannon
Topic may be closed. Thanks!