import {useRef, useState} from 'react'; import './styles.scss'; import getWindowData from '../../../index'; type VideoPlayerProps = { src: string; fallbackImage: string; }; /** * @since 3.0.0 */ export default function VideoPlayer({src, fallbackImage}: VideoPlayerProps) { const videoRef = useRef(null); const [isPlaying, setIsPlaying] = useState(false); const {assets} = getWindowData(); const togglePlay = () => { if (videoRef.current.paused) { videoRef.current.play(); setIsPlaying(true); } else { videoRef.current.pause(); setIsPlaying(false); } }; const useFallbackImage = src === null || src === undefined || src === '' || isPlaying === null || (!src.endsWith('.mp4') && !src.endsWith('.mov')); return (
{useFallbackImage ? (
{'/'}
) : (
); }