I have a React-bootstrap Carousels, each slide contains component and there is a video in each of these components, the video is auto played and looped,
I'm trying to make the video play from start when it gets shown in the slider and not continue where it originally started from.
according to React-bootstrap documentation there is a property called onSlid : Callback fired when a slide transition ends.
I want to start the video over via a callback function but I don't know how to write this function.
This is the code :
import Carousel from "react-bootstrap/Carousel";
import { useState } from "react";
import componant1 from "../SliderComponents/component1 ";
import componant2 from "../SliderComponents/component2 ";
import componant3 from "../SliderComponents/component3 ";
const Hero = () => {
const handler = () => {
// here is where I'm trying to start the video from second 0
};
return (
<div className="Hero">
<div>
<Carousel
controls={false}
fade={true}
interval={5500}
pause={false}
className="hero-slider"
onSlid={handler} //a callback fired when a slide transition ends.
>
<Carousel.Item>
<component1 />
</Carousel.Item>
<Carousel.Item>
<component2 />
</Carousel.Item>
<Carousel.Item>
<component3 />
</Carousel.Item>
</Carousel>
</div>
</div>
);
};
export default Hero;
The components that has the videos looks like this :
import videos from "../../../assets/videos/index";
const component1= () => {
return (
<div className="wrapper">
<video
className="slider-video"
src={videos.video1}
loop
autoPlay
muted
loading="lazy"
></video>
</div>
);
};
export default component1;