import * as React from "react"; import ReactPlayer from "react-player"; // import playIcon from "@sc/lsvt/src/images/playIcon.png"; // import playIcon from "./playIcon.png"; import { themeSettings } from "../theme"; import { Animation } from ".."; import { AnimationType } from "../Animation/component"; import { EditorMode } from "@sc/modules/v2/Editor/types"; // const playIcon = require("./playIcon.png"); interface VideoProps { mode?: EditorMode; children?: React.ReactNode; src?: string; style?: any; muted?: boolean; controls?: boolean; autoPlay?: boolean; onProgress?: () => any; videoThumbnail?: string; persistOnScroll?: boolean; } export const Video: React.FC = ({ style, src, muted, controls, onProgress, autoPlay, videoThumbnail, persistOnScroll, }) => { const [isPlaying, setIsPlaying] = React.useState(autoPlay); const [isInViewport, setIsInViewport] = React.useState(true); // try { // const thumbnail = videoThumbnail // ? require(`@sc/lsvt/src/images/${videoThumbnail}`) // : false; // } catch (e) { // const thumbnail = videoThumbnail; // } const thumbnail = videoThumbnail; const standardStyle = { ...style, backgroundImage: !isPlaying ? `url(${thumbnail})` : "none", backgroundRepeat: "no-repeat", backgroundSize: "cover", backgroundPosition: "center", }; React.useEffect(() => { window.addEventListener("scroll", (event) => { if (window.scrollY > 840) setIsInViewport(false); else setIsInViewport(true); }); }, []); const PlayButton = () => { const [isHovering, setIsHovering] = React.useState(false); return (

Play Icon

{/* setIsPlaying(true)} onMouseEnter={() => setIsHovering(true)} onMouseLeave={() => setIsHovering(false)} /> */}
); }; const forcedViewStyle = persistOnScroll && !isInViewport && isPlaying ? { position: "fixed", width: 400, height: 220, left: 20, top: 20, border: `5px solid ${themeSettings.default.primaryColor}`, boxShadow: "0 0 20px rgb(0,0,0,0.75)", } : {}; return ( <> {!isPlaying && }
{isPlaying && ( )}
); }; Video.defaultProps = { autoPlay: false, }; export default Video;