"use client"; import { useAudioPlayer, type AudioTrack, AudioWaveAnimation, } from "@/components/audio-player"; import { cn } from "@/lib/utils"; import { Play } from "lucide-react"; type PlayAudioButtonProps = { audioUrl: string; title: string; subtitle?: string; sourceUrl: string; type?: string; className?: string; /** Compact icon-only variant for list items */ variant?: "default" | "compact"; }; export function PlayAudioButton({ audioUrl, title, subtitle, sourceUrl, type, className, variant = "default", }: PlayAudioButtonProps) { const { currentTrack, isPlaying, play, togglePlayPause } = useAudioPlayer(); const isThisTrack = currentTrack?.url === audioUrl; const isThisPlaying = isThisTrack && isPlaying; function handleClick() { if (isThisTrack) { togglePlayPause(); } else { const track: AudioTrack = { url: audioUrl, title, subtitle, sourceUrl, type: type ?? "lecture", }; play(track); } } if (variant === "compact") { return ( ); } return ( ); }