diff --git a/src/About/About.js b/src/About/About.js
index 6c9039bb..ffa7b36d 100644
--- a/src/About/About.js
+++ b/src/About/About.js
@@ -9,46 +9,10 @@ const About = () => {
const [videoPlaying, setVideoPlaying] = useState(false);
const [currentImageIndex, setCurrentImageIndex] = useState(0);
- const toggleMute = () => {
- setIsMuted(!isMuted);
- if (audioRef.current) {
- audioRef.current.volume = isMuted ? 0.5 : 0; // Set volume to 1 if currently muted, 0 if currently unmuted
- if (isMuted) {
- audioRef.current.play().catch((err) => {
- console.error("Error playing audio:", err);
- });
- } else {
- audioRef.current.pause();
- }
- }
- };
+
+
- useEffect(() => {
- toggleMute();
- const handleLocationChange = () => {
- setIsMuted(true);
- if (audioRef.current) {
- audioRef.current.pause();
- }
- };
- }, []);
-
- useEffect(() => {
- const videoElement = document.querySelector("video");
- if (videoElement) {
- videoElement.onplay = () => {
- setVideoPlaying(true);
- };
- videoElement.onerror = () => {
- setVideoPlaying(false);
- };
- }
- if (audioRef.current) {
- audioRef.current.play().catch((err) => {
- console.error("Error playing audio:", err);
- });
- }
- }, []);
+
return (
@@ -265,45 +229,9 @@ const About = () => {
-
+
-
+
);
};
diff --git a/src/App/App.js b/src/App/App.js
index 7eafa77f..28afdab6 100644
--- a/src/App/App.js
+++ b/src/App/App.js
@@ -1,23 +1,73 @@
-import React from 'react';
-import { BrowserRouter, Route, Routes} from 'react-router-dom'; // Importing necessary components from react-router-dom
-
-// Importing components for different routes
-import Home from '../Home/Home'
+import React, { useState, useRef, useEffect } from 'react';
+import { BrowserRouter, Route, Routes } from 'react-router-dom';
+import Home from '../Home/Home';
import About from '../About/About';
import Download from '../Download/Download';
-
function App() {
+ const [isMuted, setIsMuted] = useState(false);
+ const audioRef = useRef(null);
+
+
+ const toggleMute = () => {
+ const newMutedState = !isMuted;
+ setIsMuted(newMutedState);
+ localStorage.setItem('isMuted', JSON.stringify(newMutedState));
+
+ if (audioRef.current) {
+ if (newMutedState) {
+ audioRef.current.pause();
+ } else {
+ audioRef.current.play().catch(err => console.error("Error playing audio:", err));
+ }
+ }
+ };
+
+
+ useEffect(() => {
+ const savedMuteState = JSON.parse(localStorage.getItem('isMuted'));
+
+ if (savedMuteState !== null) {
+ setIsMuted(savedMuteState);
+
+
+ if (audioRef.current && !savedMuteState) {
+ audioRef.current.play().catch(err => console.error("Error playing audio:", err));
+ }
+ } else {
+
+ if (audioRef.current) {
+ audioRef.current.play().catch(err => console.error("Error playing audio:", err));
+ }
+ }
+ }, []);
+
return (
+
+
+
+
+
} />
} />
} />
-
);
}
-export default App;
\ No newline at end of file
+export default App;
diff --git a/src/Download/Download.js b/src/Download/Download.js
index 21b89191..3808e004 100644
--- a/src/Download/Download.js
+++ b/src/Download/Download.js
@@ -10,46 +10,10 @@ const Download = () => {
const [videoPlaying, setVideoPlaying] = useState(false);
const [currentImageIndex, setCurrentImageIndex] = useState(0);
- const toggleMute = () => {
- setIsMuted(!isMuted);
- if (audioRef.current) {
- audioRef.current.volume = isMuted ? 0.5 : 0; // Set volume to 1 if currently muted, 0 if currently unmuted
- if (isMuted) {
- audioRef.current.play().catch(err => {
- console.error("Error playing audio:", err);
- });
- } else {
- audioRef.current.pause();
- }
- }
- };
+
- useEffect(() => {
- toggleMute();
- const handleLocationChange = () => {
- setIsMuted(true);
- if (audioRef.current) {
- audioRef.current.pause();
- }
- };
- }, []);
+
- useEffect(() => {
- const videoElement = document.querySelector('video');
- if (videoElement) {
- videoElement.onplay = () => {
- setVideoPlaying(true);
- };
- videoElement.onerror = () => {
- setVideoPlaying(false);
- };
- }
- if (audioRef.current) {
- audioRef.current.play().catch(err => {
- console.error("Error playing audio:", err);
- });
- }
- }, []);
return (
@@ -88,21 +52,9 @@ const Download = () => {
-
+
-
+
)
}
diff --git a/src/Home/Home.js b/src/Home/Home.js
index fa4e28db..ca839cb2 100644
--- a/src/Home/Home.js
+++ b/src/Home/Home.js
@@ -43,48 +43,7 @@ const Home = () => {
}
}
- const toggleMute = () => {
- setIsMuted(!isMuted);
- if (audioRef.current) {
- audioRef.current.volume = isMuted ? 0.5 : 0; // Set volume to 1 if currently muted, 0 if currently unmuted
- if (isMuted) {
- audioRef.current.play().catch(err => {
- console.error("Error playing audio:", err);
- });
- } else {
- audioRef.current.pause();
- }
- }
- };
-
- useEffect(() => {
- setCurrentImageIndex(0);
- toggleMute();
- const handleLocationChange = () => {
- setIsMuted(true);
- if (audioRef.current) {
- audioRef.current.pause();
- }
- };
- }, []);
- useEffect(() => {
- const videoElement = document.querySelector('video');
- if (videoElement) {
- videoElement.onplay = () => {
- setVideoPlaying(true);
- };
- videoElement.onerror = () => {
- setVideoPlaying(false);
- };
- }
- if (audioRef.current) {
- audioRef.current.play().catch(err => {
- console.error("Error playing audio:", err);
- });
- }
- }, []);
-
return (
@@ -146,21 +105,9 @@ const Home = () => {
-
-
-
+
+
+