Jump to content

How to stop background video from looping?

Go to solution Solved by tuanphan,

Recommended Posts

Site URL: http://algora.com.au

Site URL: http://algora.com.au

Landing page for this website (password is just "algora") has a section background which links to the following video.

 

This loops after 17 seconds which is a bit jarring. How can I stop it looping and just pause at the last frame?

Worst case I will have to edit the video so the last frame is extended for a long time... like an hour... hopefully there is a more natural way to do it.

 

Link to comment
  • 10 months later...

It's been a little while since you posted this so you might've found a solution but I thought I'd post this here in case someone else (like me) went through all of these questions about stopping a video loop without finding an answer.

The following code paused the lander background video on the last frame, maybe give it a try?

<script>
jQuery(document).ready(function($){    

    function no_bg_loop () {
        $('video').prop('loop', false);
    }
    $(document).ready( no_bg_loop );
    $(window).load ( no_bg_loop );
    no_bg_loop();
    setTimeout(function(){
        jQuery('video.x-mejs.has-stack-styles').on('ended', function() {
            jQuery(this)[0].pause();
        });
    },5000);
});
</script>
Link to comment
13 hours ago, black.marketing said:

It's been a little while since you posted this so you might've found a solution but I thought I'd post this here in case someone else (like me) went through all of these questions about stopping a video loop without finding an answer.

The following code paused the lander background video on the last frame, maybe give it a try?

<script>
jQuery(document).ready(function($){    

    function no_bg_loop () {
        $('video').prop('loop', false);
    }
    $(document).ready( no_bg_loop );
    $(window).load ( no_bg_loop );
    no_bg_loop();
    setTimeout(function(){
        jQuery('video.x-mejs.has-stack-styles').on('ended', function() {
            jQuery(this)[0].pause();
        });
    },5000);
});
</script>

Hey mate, where do I punch in that code? If it works it's exactly what I need!

Link to comment
  • 6 months later...
On 3/29/2022 at 7:28 AM, black.marketing said:

<script> jQuery(document).ready(function($){         function no_bg_loop () {         $('video').prop('loop', false);     }     $(document).ready( no_bg_loop );     $(window).load ( no_bg_loop );     no_bg_loop();     setTimeout(function(){         jQuery('video.x-mejs.has-stack-styles').on('ended', function() {             jQuery(this)[0].pause();         });     },5000); }); </script>

This is not working on my 7.1 site.  Is this the correct solution?

Link to comment
  • 3 months later...
On 1/27/2023 at 1:31 AM, sspec1004 said:

This is not working for me. My video is a section background at the top of my home page. Is there somewhere else I should be putting this code?

Try adding this line to top of above code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 1 month later...
On 2/1/2023 at 7:47 AM, tuanphan said:

Try adding this line to top of above code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>

 

I am still unable to get this to work on a 7.1 page. Can anyone please share how they got this to work?

Link to comment
1 hour ago, tuanphan said:

Try this new code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
jQuery(document).ready(function($){    
   $('video').removeAttr('loop');
});
</script>

 

I pasted it in config > settings > advanced > code-injection > FOOTER

Sadly no change to the video.

Link to comment
  • Solution
On 3/8/2023 at 5:33 PM, david-eh said:

I pasted it in config > settings > advanced > code-injection > FOOTER

Sadly no change to the video.

Try change to this

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
jQuery(document).ready(function($){    
  setTimeout( function() {
         $('video').removeAttr('loop');
    }, 5000);
  
  
});
</script>

If it still doesn't work, keep this code in Code Injection & let me know, we can check it again easier

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
On 3/10/2023 at 10:47 AM, tuanphan said:

Try change to this

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
jQuery(document).ready(function($){    
  setTimeout( function() {
         $('video').removeAttr('loop');
    }, 5000);
  
  
});
</script>

If it still doesn't work, keep this code in Code Injection & let me know, we can check it again easier

That worked! Thanks a lot for your help.

Link to comment
On 3/10/2023 at 9:47 AM, tuanphan said:

Try change to this

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
jQuery(document).ready(function($){    
  setTimeout( function() {
         $('video').removeAttr('loop');
    }, 5000);
  
  
});
</script>

If it still doesn't work, keep this code in Code Injection & let me know, we can check it again easier

You are an absolute saviour.

Link to comment
  • 1 month later...

Well, this sucks.

I added the code that tuanphan posted to my footer during my trial period and it worked like a charm.

Just decided to subscribe and now I find out that the code is being ignored because access to the Code Injection feature is an additional subscription tier more than the Personal site subscription I purchased 😤

Feels like a bait and switch 😒

Link to comment
On 4/28/2023 at 3:39 AM, Cy832D3f3nd0R said:

Well, this sucks.

I added the code that tuanphan posted to my footer during my trial period and it worked like a charm.

Just decided to subscribe and now I find out that the code is being ignored because access to the Code Injection feature is an additional subscription tier more than the Personal site subscription I purchased 😤

Feels like a bait and switch 😒

You can add it to Markdown Block on Footer (however this, maybe won't work in future)

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 1 month later...

This code works on 7.1 provided t is inserted into the page itself.

Page > Settings > Advanced

This will also limit the load on your site as it only loads on that page and not the entire site. Putting it in the header or footer loads it in every page, decreasing performance..

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
jQuery(document).ready(function($){    
  setTimeout( function() {
         $('video').removeAttr('loop');
    }, 5000);
});
</script>

 

Link to comment
On 3/10/2023 at 1:47 AM, tuanphan said:

Try change to this

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
jQuery(document).ready(function($){    
  setTimeout( function() {
         $('video').removeAttr('loop');
    }, 5000);
  
  
});
</script>

If it still doesn't work, keep this code in Code Injection & let me know, we can check it again easier

This does not work for our site... https://the805room.com/

 

Video in the header keeps looping sadly.  Please advise.

Link to comment
  • 1 month later...
  • 2 months later...

is there a way to target this code to a single video on the page?

i used this code and i have multiple looping videos on my page but i only want to stop the looping of one video.

this is my website: https://www.flexmedia.is/

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
jQuery(document).ready(function($){    
  setTimeout( function() {
         $('video').removeAttr('loop');
    }, 5000);
  
  
});
</script>
Link to comment
On 10/27/2023 at 11:29 PM, EgillGauti said:

is there a way to target this code to a single video on the page?

i used this code and i have multiple looping videos on my page but i only want to stop the looping of one video.

this is my website: https://www.flexmedia.is/

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
jQuery(document).ready(function($){    
  setTimeout( function() {
         $('video').removeAttr('loop');
    }, 5000);
  
  
});
</script>

Change this line

 $('video').removeAttr('loop');

to this

 $('#enter-block-id video').removeAttr('loop');

Use this tool to find block id: https://chrome.google.com/webstore/detail/squarespace-id-finder/igjamfnifnkmecjidfbdipieoaeghcff

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.