import React from 'react'; import { BrowserRouter as Router, Routes, Route, Navigate, Link } from 'react-router-dom'; import Hero from './components/Hero'; import SingleAnalysis from './components/SingleAnalysis'; import BatchAnalysis from './components/BatchAnalysis'; const App: React.FC = () => { const [isPlaying, setIsPlaying] = React.useState(false); const audioRef = React.useRef(null); React.useEffect(() => { const audio = audioRef.current; if (!audio) return; audio.volume = 0.5; // 1. Try to autoplay immediately const playPromise = audio.play(); if (playPromise !== undefined) { playPromise .then(() => setIsPlaying(true)) .catch((error) => { console.log("Autoplay blocked. Waiting for user interaction.", error); setIsPlaying(false); }); } // 2. Add a global click listener as a fallback // As soon as the user clicks ANYWHERE, we start the audio const handleUserInteraction = () => { if (audio.paused) { audio.play() .then(() => { setIsPlaying(true); // Remove listener once successful document.removeEventListener('click', handleUserInteraction); }) .catch(e => console.error("Play failed even after interaction:", e)); } }; document.addEventListener('click', handleUserInteraction); return () => { document.removeEventListener('click', handleUserInteraction); }; }, []); const toggleAudio = () => { if (audioRef.current) { if (isPlaying) { audioRef.current.pause(); } else { audioRef.current.play(); } setIsPlaying(!isPlaying); } }; return (
{/* Global Nav / Logo - Fixed and High Z-Index */}
{/* Logo Icon */}
Logo
Samsung Prism Prototype {/* Audio Toggle */}
{!isPlaying && (
{/* Gradient Border Container */}
{/* Inner Glass Content */}
✨ Don't miss the magic! 🎧
{/* Arrow pointing to button */}
)}
); }; export default App;