|
@@ -1,9 +1,19 @@
|
1
|
|
-import React from 'react';
|
2
|
|
-import { Box } from '@mui/material';
|
|
1
|
+import React, { useRef, useState } from 'react';
|
|
2
|
+import { Box, Button } from '@mui/material';
|
3
|
3
|
import PropTypes from 'prop-types';
|
4
|
|
-import videoAds from "../../assets/video/amberads.mp4"
|
|
4
|
+import videoAds from "../../assets/video/amberads.mp4";
|
5
|
5
|
|
6
|
6
|
const VideoAds = ({ video_url, height, width }) => {
|
|
7
|
+ const videoRef = useRef(null);
|
|
8
|
+ const [isMuted, setIsMuted] = useState(true);
|
|
9
|
+
|
|
10
|
+ const toggleMute = () => {
|
|
11
|
+ if (videoRef.current) {
|
|
12
|
+ videoRef.current.muted = !isMuted;
|
|
13
|
+ setIsMuted(!isMuted);
|
|
14
|
+ }
|
|
15
|
+ };
|
|
16
|
+
|
7
|
17
|
return (
|
8
|
18
|
<Box
|
9
|
19
|
sx={{
|
|
@@ -11,19 +21,20 @@ const VideoAds = ({ video_url, height, width }) => {
|
11
|
21
|
overflow: 'hidden',
|
12
|
22
|
width: '100%',
|
13
|
23
|
height: {
|
14
|
|
- xs:230,
|
15
|
|
- sm:330,
|
16
|
|
- md:520,
|
17
|
|
- lg:675,
|
18
|
|
- xl:850
|
|
24
|
+ xs: 230,
|
|
25
|
+ sm: 330,
|
|
26
|
+ md: 520,
|
|
27
|
+ lg: 675,
|
|
28
|
+ xl: 850,
|
19
|
29
|
},
|
20
|
30
|
}}
|
21
|
31
|
>
|
22
|
32
|
<video
|
23
|
|
- src={videoAds}
|
|
33
|
+ ref={videoRef}
|
|
34
|
+ src={video_url || videoAds}
|
24
|
35
|
autoPlay
|
25
|
36
|
loop
|
26
|
|
- muted
|
|
37
|
+ muted={isMuted}
|
27
|
38
|
playsInline
|
28
|
39
|
style={{
|
29
|
40
|
position: 'absolute',
|
|
@@ -33,6 +44,23 @@ const VideoAds = ({ video_url, height, width }) => {
|
33
|
44
|
height: 'auto',
|
34
|
45
|
}}
|
35
|
46
|
/>
|
|
47
|
+ <Button
|
|
48
|
+ onClick={toggleMute}
|
|
49
|
+ variant="contained"
|
|
50
|
+ sx={{
|
|
51
|
+ position: 'absolute',
|
|
52
|
+ bottom: 16,
|
|
53
|
+ right: 16,
|
|
54
|
+ zIndex: 1,
|
|
55
|
+ backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
56
|
+ color: 'white',
|
|
57
|
+ '&:hover': {
|
|
58
|
+ backgroundColor: 'rgba(0, 0, 0, 0.7)',
|
|
59
|
+ },
|
|
60
|
+ }}
|
|
61
|
+ >
|
|
62
|
+ {isMuted ? 'Unmute' : 'Mute'}
|
|
63
|
+ </Button>
|
36
|
64
|
</Box>
|
37
|
65
|
);
|
38
|
66
|
};
|
|
@@ -44,7 +72,7 @@ VideoAds.propTypes = {
|
44
|
72
|
};
|
45
|
73
|
|
46
|
74
|
VideoAds.defaultProps = {
|
47
|
|
- video_url: 'https://www.w3schools.com/html/mov_bbb.mp4',
|
|
75
|
+ video_url: videoAds,
|
48
|
76
|
height: '300px',
|
49
|
77
|
width: '100%',
|
50
|
78
|
};
|