"use client"; import { useAudioPlayer } from "@/hooks/useAudioPlayer"; interface AudioPlayerProps { audioUrl: string | null; } function formatTime(seconds: number): string { if (!isFinite(seconds) || isNaN(seconds)) return "0:00"; const m = Math.floor(seconds / 60); const s = Math.floor(seconds % 60); return `${m}:${s.toString().padStart(2, "0")}`; } export default function AudioPlayer({ audioUrl }: AudioPlayerProps) { const { isPlaying, currentTime, duration, volume, toggle, seek, setVolume } = useAudioPlayer(audioUrl); if (!audioUrl) return null; const progress = duration > 0 ? (currentTime / duration) * 100 : 0; const handleDownload = () => { const a = document.createElement("a"); a.href = audioUrl; a.download = "vibepod-output.wav"; a.click(); }; return (

Audio Player

{/* Waveform / progress bar */}
{ const rect = e.currentTarget.getBoundingClientRect(); const ratio = (e.clientX - rect.left) / rect.width; seek(ratio * duration); }} >
{formatTime(currentTime)} {formatTime(duration)}
{/* Controls row */}
{/* Play/Pause */} {/* Duration info */}
{formatTime(currentTime)} / {formatTime(duration)}
{/* Volume control */}
{volume === 0 ? ( <> ) : volume < 0.5 ? ( <> ) : ( <> )} setVolume(parseFloat(e.target.value))} className="w-20" aria-label="Volume" />
); }