Hello, on my website I have a portfolio of videos using Lightbox. When you open a video and play it, if you exit the video the sound continues playing. Is there a way around this or a way to fix it? If this requires custom coding please let me know what code to use and where to put it. Thank you in advance!
(Note: I’m @bartekkustra - I created new account a while back)
There are two ways you can approach this:
Option 1
Instead of using custom lightbox you can use Webflow Lightbox. I noticed you’re using Collection List there to display those, so feel free to check the community-made Dynamic Lightbox Code:
That way if you close the lightbox the video will just stop
Option 2
The other way is - instead of using VIDEO field in Collection and VIDEO widget in Webflow - to build custom VIMEO player inside of your custom modal. There are great docs on that here:
Having that done you can then access the Vimeo Player SDK methods (Player SDK: Reference | Vimeo Developer) that will allow you to play/pause the video. You’ll be able to call those by simply attaching a custom code to the closing icon of your custom modal, eg:
// First, visit the following Vimeo GitHub page to find the Vimeo Player API script to include on your page: https://github.com/vimeo/player.js/
// The code below will pause the video when the bootstrap modal is closed (Bootstrap 4 is what I used)
// Place the code below inside of a script tag
// Replace the id code ("#your-modal-id") in the code below, with the id of your bootstrap modal, the id is found on the most outer div of the modal code provided by bootstrap
(document).ready(function() {
(’#your-modal-id’).on(‘hidden.bs.modal’, function () {
player.pause();
});
});