Hello everyone!
After spending hours trying to make this work have ended up asking for help on the forum for the first time.
All I need is that, when having a Nestable Slider that contains a video, if you are playing that video and change to a different slide it’s paused automatically. This way you don’t have the sound playing in the background from a video is not visible.
The SplideJS library Bricks uses includes this feature inside its video extension, as you can read it says “controls play/pause when the carousel moves”. I assume Bricks includes this video extension but the autopause/autoplay when moving the carousel is not working and there’s no option to activate it. I have been trying to get a script that makes it possible but after many attempts I didn’t succeed.
This is the page where I need this to work. On the second slide of every slider there’s a video.
I think the closer I got was the next script, but still didn’t work:
<script>
// Get the Splide instance
const splideId = window.bricksData.splideInstances['project-slider'];
// Add event listener for when the slide is changed
splideInstance.on('moved', function(newIndex) {
// Get the current slide element
var currentSlide = splideInstance.Components.Elements.slides[newIndex];
// Find the video element inside the current slide
var videoElement = currentSlide.querySelector('video');
// Pause the video if it's playing
if (videoElement && !videoElement.paused) {
videoElement.pause();
}
});
</script>
Can someone please help me with this?
Thank you in advance!