Pop-out HTML5 audio player for KPTZ 91.9 FM, Port Townsend WA.
Displays live stream audio with real-time now-playing data (track, artist, album art, show name/time) pulled from Spinitron.
| File | Purpose |
|---|---|
player.html |
The pop-out player. Hosted on GitHub Pages. |
worker.js |
Cloudflare Worker — CORS proxy for Spinitron API. |
wix-embed.html |
Snippet to paste into a Wix HTML iframe embed element. |
The Spinitron v2 API blocks direct browser requests (no CORS headers), so a server-side proxy is required. A Cloudflare Worker on the free tier handles this cleanly and keeps your API key out of the client code.
kptz-spinitronworker.jsSPINITRON_API_KEYhttps://kptz-spinitron.YOUR-SUBDOMAIN.workers.devOpen player.html and find the CONFIG block near the top of the <script> section:
const CONFIG = {
streamUrl: 'https://kptz.streamguys1.com/live-aac',
proxyBase: 'https://YOUR-WORKER.workers.dev', // ← paste your Worker URL here
pollInterval: 30000,
};
Replace YOUR-WORKER.workers.dev with your actual Worker URL.
Logo image: The <img> tag in the header currently points to the logo on your Wix static CDN. If you want a local copy, drop a logo.png into this repo and change the src to ./logo.png.
kptz-player)player.html (and optionally logo.png) to the main branchmain, folder / (root)https://YOUR-USERNAME.github.io/kptz-player/Your player will be live at:
https://YOUR-USERNAME.github.io/kptz-player/player.html
wix-embed.html and update the playerUrl variable to match your GitHub Pages URL from step 3wix-embed.html into the code editorVisitor clicks "Listen Live" button (Wix embed)
↓
window.open() opens player.html in a named pop-out window
↓
player.html loads; visitor clicks Play
↓
HTML5 <audio> tag connects to StreamGuys stream URL directly
↓
JavaScript polls Cloudflare Worker every 30 seconds
↓
Worker forwards request to Spinitron API with Bearer auth
↓
Spinitron returns current spin JSON
↓
Player updates track title, artist, album, art, show info
The pop-out window has a fixed name (kptz-player), so clicking the
“Listen Live” button again focuses the existing window rather than
opening a second one — the stream keeps playing uninterrupted.
| Field | Source | Used for |
|---|---|---|
spin.song |
/spins |
Track title |
spin.artist |
/spins |
Artist name |
spin.release |
/spins |
Album name |
spin.image |
/spins |
Album art URL |
spin.playlist_id |
/spins |
Links to playlist for show lookup |
playlist.show_id |
/playlists/:id |
Links to show |
playlist.start/end |
/playlists/:id |
Show air times |
show.title |
/shows/:id |
Program name |
show_id is present in the playlist. If there’s no show attached (automation / freeform), that section stays hidden.width and height in wix-embed.html to taste.