Skip to content

Now Playing

A music player on the Live Activity capsule: a pill with cover, title, level bars and play, that opens into a scrubber and controls. Your app owns playback.

On this page
Used for
  • A music or podcast player in the corner of an app
  • A mini player in a header that opens into full controls
  • Any audio the app owns: the capsule shows state, your code plays it

Examples

Page

Compact pill

Tiles

Remote control

Empty, pending and read-only

Installation

npx knowns-ui@latest add now-playing
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

track
{ title, artist, album?, duration?, cover?, hue? } | null
What is playing; null is the empty state. `cover` is an http or data: URL or a node; without it a gradient is drawn.
source
string
Where it plays ("Music", a device), small above the title in the tiles.
position / positionUpdatedAt
number / number (ms)
Seconds played, and when it was read. With the second, the time runs locally between pushes and a stale push never moves it back.
duration
number
Defaulttrack.duration
Seconds in the track.
playing / pending
boolean
Pending disables the controls and marks the player busy.
onPlayPause / onNext / onPrev
() => void
Next and previous are disabled without a handler.
onSeek
(seconds) => void
Optional. Without it the scrubber is a read-only progress bar.
volume / onVolume / muted / onMute
number (0 to 100) / (v) => void / boolean / () => void
Volume and mute. Each is optional.
size
"capsule" | "auto" | "large" | "medium" | "compact"
Default"capsule"
Capsule is the Live Activity pill. The others are tiles that fill their container; auto picks by width (340 and 460 px).
labels
Partial<NowPlayingLabels>
DefaultEnglish
Every visible and spoken string, including how the scrubber and volume are read.
levels
number[] (0 to 1)
Defaultstatic
Heights of the level bars. Omit for a calm static skyline.
markFrom
number
Marks the end of the scrubber from this second.
expanded / defaultExpanded / onExpandedChange
boolean
Defaultfalse
Open the card.
compact / tone / accent
boolean / "auto" | "inverse" | "surface" / color
Same as Live Activity.
useAudioPlayer(src)
{ position, duration, playing, volume, audio, toggle, seek, setVolume }
Optional: wires an audio element to the props above.

What it handles

  1. 01Shows cover art, title and artist, level bars and a play or pause button in one pill. Press the pill and it opens into a card with the scrubber, elapsed and remaining time, previous, next and volume.
  2. 02Works as a remote display: when the state is pushed from outside every second or two, give `positionUpdatedAt` and the time keeps running locally between pushes. A push a little behind the screen is ignored, so it never jumps back.
  3. 03Comes as a tile too: compact, medium or large, filling its container. `size="auto"` picks one from the container's width; an explicit size needs no container queries, for older phones.
  4. 04Has an empty "nothing playing" state and a `pending` state that disables the controls while a command is in flight. Every string is a prop, so it can be translated. Without `onSeek` the scrubber is a read-only progress bar.
  5. 05Stays headless: you pass the position and the handlers. The optional useAudioPlayer hook wires one audio element to the same props.
  6. 06Draws a gradient cover from the title and artist when there is no art, so a track without a picture still has a stable face.

States

Open or close
The card folds open under the pill, the pill never moves
180ms, ease out
Playing or paused
The level bars rise to full and the button swaps its icon
120ms, ease out
Press a filled button
Scales to 0.97
120ms
Reduced motion
Every change lands at once
0ms

Works with

When to use

When to use

  • A music or podcast player in the corner of an app that opens into full controls.
  • Audio your app already plays: the capsule shows state and sends the presses back.

When not to use

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Now Playing to my app and wire it to my own data.
  • I need a music or podcast player in the corner of an app that opens into full controls. Set that up with the Knowns UI Now Playing.
  • Which Now Playing props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "now-playing" }) and search_docs({ query: "now playing" }).

Need help?

Stuck on Now Playing, or found something off? We read every message.