jarvis Posted March 21, 2019 Share Posted March 21, 2019 Hi All, I have a Bootstrap (v4) carousel. It has numerous slides but one slide has a video. For example: <div class="carousel-item" data-interval="10000"> <video id="player" loop> <source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" type="video/mp4"><br> Your browser does not support the video tag. </video> <div class="carousel-caption d-md-block"> <h3 data-animation="animated flipInX"> This is the caption for slide 4 </h3> </div> </div> What I'm trying to do, is set the video to play only when you're on that slide (active) and pause when you either scroll away (via a click on the carousel arrows/indicators or the carousel interval). Therefore, I will use the event functionality (https://getbootstrap.com/docs/4.0/components/carousel/#events). As I'm using HTML 5 video tags, this is my solution: $('#carousel').carousel().on('slide.bs.carousel',function(){ $('.carousel-item').find('video').each(function(){ this.pause(); }); }); $('#carousel').carousel().on('slide.bs.carousel',function(){ $('.carousel-item active').find('video').each(function(){ this.play(); }); }); Unfortunately, it doesn't seem to work but I can't see why? Am I missing something very obvious?? Many thanks in advanced Quote Link to comment https://forums.phpfreaks.com/topic/308491-bootstrap-carousel-startstop-video-on-slide/ Share on other sites More sharing options...
Dana Posted April 17, 2021 Share Posted April 17, 2021 Hi. I am trying to achieve something similar in react. did u manage to figure it out? 😁 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/308491-bootstrap-carousel-startstop-video-on-slide/#findComment-1585872 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.