import Link from 'next/link'; import { StatusCard } from '@/components/admin/dashboard'; import { siteSettings } from '@/lib/services/site-settings'; import { requireStaff } from '@/lib/admin/guard'; import { EmbedSnippet } from './embed-snippet'; export const dynamic = 'force-dynamic'; export const metadata = { title: 'Radio Embed' }; export default async function AdminRadioEmbedPage() { await requireStaff(); // Read radio embed-related website_settings. siteSettings.get() already // swallows DB errors and serves fallbacks, but wrap defensively anyway so a // throw never blanks the page. let streamUrl = ''; let radioName = 'Radio'; let nowPlayingApiUrl = ''; try { streamUrl = (await siteSettings.get('radio_stream_url', '')) ?? ''; radioName = (await siteSettings.get('radio_name', null)) ?? (await siteSettings.get('hotel_name', 'Radio')) ?? 'Radio'; nowPlayingApiUrl = (await siteSettings.get('radio_now_playing_api_url', '')) ?? ''; } catch { streamUrl = ''; } streamUrl = streamUrl.trim(); nowPlayingApiUrl = nowPlayingApiUrl.trim(); const hasStream = streamUrl !== ''; // Copy-ready embed snippets. Built server-side from the configured stream URL // so what staff copy matches what the preview renders. const audioSnippet = hasStream ? `` : ''; const iframeSnippet = hasStream ? `` : ''; return (

Radio Embed

Copy-ready embed code for the live stream. Read-only — nothing here writes to the database. Configure the stream URL in{' '} Radio Settings ( radio_stream_url).

{!hasStream ? (

No stream URL configured

There is no radio_stream_url set, so there is nothing to embed yet. Open{' '} Radio Settings and fill in the Main stream URL field under{' '} AzureCast & Stream. Once saved, return here to copy the embed snippet and preview the player.

Go to Radio Settings

) : ( <>

Live preview

This is the bare <audio> player as visitors will see it. Press play to confirm the stream is reachable.

{/* eslint-disable-next-line jsx-a11y/media-has-caption */}

Source: {streamUrl}

)}
); }