import { useRef, useState, useEffect } from 'react'; import { Box, Button } from '@mui/material'; import PropTypes from 'prop-types'; import videoAds from "../../assets/video/amberads.mp4"; const VideoAds = ({ video_url, height, width }) => { const videoRef = useRef(null); const [isMuted, setIsMuted] = useState(true); useEffect(() => { if (videoRef.current) { videoRef.current.muted = true; // Ensure video starts muted for autoplay videoRef.current.play().catch((err) => { console.warn('Autoplay failed:', err); }); } }, []); const toggleMute = () => { if (videoRef.current) { videoRef.current.muted = !isMuted; setIsMuted(!isMuted); } }; return ( ); }; VideoAds.propTypes = { video_url: PropTypes.string.isRequired, height: PropTypes.string, width: PropTypes.string, }; VideoAds.defaultProps = { video_url: videoAds, height: '300px', width: '100%', }; export default VideoAds;