import { Button } from "../ui/button"; import { Play, Pause } from "lucide-react"; import { cn } from "@/lib/utils"; interface PlaybackControlsProps { isPlaying: boolean; currentTime: number; duration: number; onTogglePlayPause: () => void; onSeek: (time: number) => void; } export default function PlaybackControls({ isPlaying, currentTime, duration, onTogglePlayPause, onSeek, }: PlaybackControlsProps) { function formatTime(seconds: number) { if (!isFinite(seconds) || isNaN(seconds) || seconds < 0) return '0:00'; const mins = Math.floor(seconds / 60); const secs = Math.floor(seconds % 60); return `${mins}:${secs.toString().padStart(2, '0')}`; } function handleSeekChange(e: React.ChangeEvent) { onSeek(parseFloat(e.target.value)); } const progress = duration > 0 ? (currentTime / duration) * 100 : 0; return (
{formatTime(currentTime)}
{/* Custom Track Background */}
{/* Interactive Input */} {/* Custom Thumb (visual only, follows progress) */}
{formatTime(duration)}
); }