import { Pause, Play } from "lucide-react"; import { useScopedT } from "@/contexts/I18nContext"; import { cn } from "@/lib/utils"; import { Button } from "../ui/button"; interface PlaybackControlsProps { isPlaying: boolean; currentTime: number; duration: number; onTogglePlayPause: () => void; onSeek: (time: number) => void; } export default function PlaybackControls({ isPlaying, currentTime, duration, onTogglePlayPause, onSeek, }: PlaybackControlsProps) { const t = useScopedT("common"); 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)}
); }