diff --git a/src/app/page.tsx b/src/app/page.tsx
index d2f59c2..d19374e 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -10,6 +10,7 @@ import TestimonialCardOne from '@/components/sections/testimonial/TestimonialCar
import ContactFaq from '@/components/sections/contact/ContactFaq';
import FooterMedia from '@/components/sections/footer/FooterMedia';
import { Award, Sparkles, Users, Music } from "lucide-react";
+import BackgroundMusicPlayer from '@/components/BackgroundMusicPlayer';
export default function LandingPage() {
return (
@@ -25,6 +26,7 @@ export default function LandingPage() {
secondaryButtonStyle="glass"
headingFontWeight="normal"
>
+
(null);
+ const [isPlaying, setIsPlaying] = useState(false);
+ const [volume, setVolume] = useState(0.5);
+ const [isLoaded, setIsLoaded] = useState(false);
+ const [error, setError] = useState(null);
+
+ useEffect(() => {
+ const audio = audioRef.current;
+ if (!audio) return;
+
+ audio.volume = volume;
+ }, [volume]);
+
+ useEffect(() => {
+ const audio = audioRef.current;
+ if (!audio) return;
+
+ const handleCanPlay = () => {
+ setIsLoaded(true);
+ setError(null);
+ };
+
+ const handleError = () => {
+ setError('Failed to load audio');
+ setIsPlaying(false);
+ };
+
+ const handleEnded = () => {
+ audio.currentTime = 0;
+ audio.play().catch(() => {
+ setIsPlaying(false);
+ });
+ };
+
+ audio.addEventListener('canplay', handleCanPlay);
+ audio.addEventListener('error', handleError);
+ audio.addEventListener('ended', handleEnded);
+
+ return () => {
+ audio.removeEventListener('canplay', handleCanPlay);
+ audio.removeEventListener('error', handleError);
+ audio.removeEventListener('ended', handleEnded);
+ };
+ }, []);
+
+ const togglePlayPause = async () => {
+ const audio = audioRef.current;
+ if (!audio) return;
+
+ try {
+ if (isPlaying) {
+ audio.pause();
+ setIsPlaying(false);
+ } else {
+ await audio.play();
+ setIsPlaying(true);
+ }
+ } catch (err) {
+ setError('Autoplay policy prevented playback');
+ setIsPlaying(false);
+ }
+ };
+
+ const handleVolumeChange = (e: React.ChangeEvent) => {
+ const newVolume = parseFloat(e.target.value);
+ setVolume(newVolume);
+ };
+
+ return (
+
+
+
+
+
+
Background Music
+
+ {isLoaded ? 'Ready' : 'Loading...'}
+
+
+
+ {error && (
+
+ {error}
+
+ )}
+
+
+
+
+
+ {volume === 0 ? (
+
+ ) : (
+
+ )}
+
+
+ {Math.round(volume * 100)}%
+
+
+
+
+
+ {isPlaying ? 'Now playing' : 'Paused'}
+
+
+
+ );
+}
\ No newline at end of file