Browse Source

change video

master
azri 1 week ago
parent
commit
e46915b278
3 changed files with 41 additions and 13 deletions
  1. BIN
      src/assets/video/amberads.mp4
  2. 39
    11
      src/components/VideoAds/VideoAds.jsx
  3. 2
    2
      src/index.js

BIN
src/assets/video/amberads.mp4 View File


+ 39
- 11
src/components/VideoAds/VideoAds.jsx View File

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
 import PropTypes from 'prop-types';
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
 const VideoAds = ({ video_url, height, width }) => {
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
   return (
17
   return (
8
     <Box
18
     <Box
9
       sx={{
19
       sx={{
11
         overflow: 'hidden',
21
         overflow: 'hidden',
12
         width: '100%',
22
         width: '100%',
13
         height: {
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
       <video
32
       <video
23
-        src={videoAds}
33
+        ref={videoRef}
34
+        src={video_url || videoAds}
24
         autoPlay
35
         autoPlay
25
         loop
36
         loop
26
-        muted
37
+        muted={isMuted}
27
         playsInline
38
         playsInline
28
         style={{
39
         style={{
29
           position: 'absolute',
40
           position: 'absolute',
33
           height: 'auto',
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
     </Box>
64
     </Box>
37
   );
65
   );
38
 };
66
 };
44
 };
72
 };
45
 
73
 
46
 VideoAds.defaultProps = {
74
 VideoAds.defaultProps = {
47
-  video_url: 'https://www.w3schools.com/html/mov_bbb.mp4',
75
+  video_url: videoAds,
48
   height: '300px',
76
   height: '300px',
49
   width: '100%',
77
   width: '100%',
50
 };
78
 };

+ 2
- 2
src/index.js View File

32
 const root = ReactDOM.createRoot(document.getElementById('root'));
32
 const root = ReactDOM.createRoot(document.getElementById('root'));
33
 root.render(
33
 root.render(
34
   <Provider store={store}>
34
   <Provider store={store}>
35
-    {/* <App /> */}
36
-    <Maintainance/>
35
+    <App />
36
+    {/* <Maintainance/> */}
37
   </Provider>
37
   </Provider>
38
 );
38
 );
39
 
39
 

Loading…
Cancel
Save