Background video pause button

Hi there,

I’d like to pause a background video with a button. Is that possible?
Can someone post a code to do that?

Thanks

Give your button an ID (not class!) of pause-videos.

Add this in your Site Dashboard > Custom Code > Footer Code

<script>
var Webflow = Webflow || [];
Webflow.push(function() {
  $('#pause-videos').click(function() {
    $('video').get(0).pause();
    return false;
  });
});
</script>

Save and publish (cannot view in designer)


Also, feel free to contact me for further code help and/or customization of third-party plugins

2 Likes

Thanks a lot @samliew. It works flawlessly!

Hi @samliew is it possible to automatically stop the background video after one play?

1 Like