import { useEffect, useState } from "react"; import { useNowPlaying } from "./shared/useNowPlaying.ts"; import { useSpectrum } from "./shared/useSpectrum.ts"; import { useElapsed } from "./shared/useElapsed.ts"; import { fmtMs, fmtClock, fmtClockSec, fmtJpDate } from "./shared/format.ts"; const KAOMOJI_STREAM = ["(´。• ᵕ •。`)", "٩(◕‿◕)۶", "(。◕‿◕。)", "(>ω<)", "(✿◠‿◠)"]; interface Cfg { station: string; tz: string; tuneInUrl: string; branding: boolean; } interface Listeners { current: number; peak: number; } interface Props { cfg: Cfg; listeners: Listeners; } export function StreamDenpa({ cfg, listeners }: Props) { const np = useNowPlaying(); const spectrum = useSpectrum(); const [now, setNow] = useState(() => new Date()); useEffect(() => { const id = setInterval(() => setNow(new Date()), 1000); return () => clearInterval(id); }, []); const startedAt = np ? Number(np.started_at) : 0; const duration = np ? Number(np.duration) : 0; const elapsed = useElapsed(startedAt, duration); if (!np) return
; const pct = duration > 0 ? (elapsed / duration) * 100 : 0; const upNext = np.up_next.slice(0, 4); const nameJp = "ラジオ"; const channel = "CH.01"; const bitrate = 192; const codec = "MP3/OPUS"; const genre = "auto"; const uptime = "—"; return (