|
@@ -1,4 +1,4 @@
|
1
|
|
-import React, { useRef, useState } from 'react';
|
|
1
|
+import { useRef, useState, useEffect } from 'react';
|
2
|
2
|
import { Box, Button } from '@mui/material';
|
3
|
3
|
import PropTypes from 'prop-types';
|
4
|
4
|
import videoAds from "../../assets/video/amberads.mp4";
|
|
@@ -7,6 +7,15 @@ const VideoAds = ({ video_url, height, width }) => {
|
7
|
7
|
const videoRef = useRef(null);
|
8
|
8
|
const [isMuted, setIsMuted] = useState(true);
|
9
|
9
|
|
|
10
|
+ useEffect(() => {
|
|
11
|
+ if (videoRef.current) {
|
|
12
|
+ videoRef.current.muted = true; // Ensure video starts muted for autoplay
|
|
13
|
+ videoRef.current.play().catch((err) => {
|
|
14
|
+ console.warn('Autoplay failed:', err);
|
|
15
|
+ });
|
|
16
|
+ }
|
|
17
|
+ }, []);
|
|
18
|
+
|
10
|
19
|
const toggleMute = () => {
|
11
|
20
|
if (videoRef.current) {
|
12
|
21
|
videoRef.current.muted = !isMuted;
|