import { useAudio } from "rooks";
export default function App() {
const audioSrc = "https://example.com/audio.mp3";
const [{ isPlaying, isMuted }, audioRef] = useAudio({ autoPlay: false });
const handlePlay = () => audioRef.current.play();
const handlePause = () => audioRef.current.pause();
const handleToggleMute = () => (audioRef.current.muted = !isMuted);
return (
<>
<audio ref={audioRef} src={audioSrc} />
<button onClick={handlePlay}>Play</button>
<button onClick={handlePause}>Pause</button>
<button onClick={handleToggleMute}>{isMuted ? "Unmute" : "Mute"}</button>
</>
);
}