A self-contained page that drives the ai-speaker MCP server over
Streamable HTTP, so playback can be controlled from the TV remote.
Player state
- player_status is the single source of truth. Polling syncs playing,
source, title, elapsed, duration, progress and remaining once per
second while playing, and stops when playback ends.
- Switching tracks opens a short freeze window (pendingSource): the
server keeps reporting the previous source for a few hundred ms, and
without the freeze the list highlight would snap back to the old row
and then jump forward again. While frozen only progress is updated.
- Clicking the row that is already playing is a no-op instead of
restarting it. force=true is reserved for repeat-one and manual
prev/next, which must replay even when the source is unchanged.
List rendering
- The list is rebuilt only on boot, after list_music, and on explicit
refresh. Play state changes go through refreshPlayingMark, which
toggles classes on existing nodes. Rebuilding on every poll popped the
entrance animation and reset the remote focus once per second.
- A loading overlay covers the list during the initial load and manual
refresh, with an 8s timeout so a hung request cannot leave it stuck.
Playback modes
- List loop, shuffle and repeat-one, cycling from one button. prev/next
use pickByManual so they still move when repeat-one is active.
- Natural end of a track advances according to the mode; the check
requires elapsed to be within 3s of duration so a manual stop does not
trigger it.
UI notes
- Volume uses the 0-100 scale the server reports, with remote left/right
stepping by 1. The UI keeps the requested value rather than the
returned actual, which the speaker quantizes to roughly 5% steps and
would otherwise make +1 appear to fall back.
- Icons are inline SVG instead of emoji to match the dark theme.
- Avoids CSS the bundled WebView 84 does not support: inset shorthand
collapsed the overlay to a small box, and filter on a gradient element
made the play button disappear when focused.
mcp.sh is a small helper for calling a single MCP tool from the shell.