I have a video with specific sequences in it. My requirement is to autoplay the video on page load and thereon, pause at 15s. When the user scrolls with the mouse, instead of scrolling the page, the video must continue to play until the next pause at 45s. This is repeated for 10 such pauses of the video.
Finally, after the 10th pause, the video plays to completion.
What I have is a component that plays and pauses the video at 15s, but I'm not sure if I'm controlling the timeline correctly, or whether we should use a timeline at all.
import React, { useEffect, useRef } from "react";
import { gsap } from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
gsap.registerPlugin(ScrollTrigger);
const IntroVideo = () => {
const introVideoRef = useRef();
const tl = useRef();
useEffect(() => {
tl.current = gsap.timeline().to(introVideoRef.current, {
currentTime: 15,
duration: 15,
});
// ScrollTrigger.create({
// trigger: introVideoRef.current,
// scrub: true,
// markers: true,
// onUpdate: function (self) {
// console.log("scroll triggered");
// },
// });
}, []);
return (
<div className="introVideoContainer">
<video autoPlay controls="" ref={introVideoRef} src="output.mp4"></video>
</div>
);
};
export default IntroVideo;
Any help is appreciated. Thank you!