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-playingFor Claude Code, Cursor or Codex: installs it and wires the props to your own data.
Paste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install prompt
Install Now playing from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/now-playing
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add now-playing
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- components/ui/knowns/spinner.tsx
- components/ui/knowns/button.tsx
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- components/ui/knowns/status-dot.tsx
- components/ui/knowns/live-activity/live-activity.tsx
- components/ui/knowns/live-activity/activity-utils.ts
- components/ui/knowns/slider.tsx
- components/ui/knowns/now-playing/now-playing.tsx
- components/ui/knowns/now-playing/now-playing-utils.ts
- components/ui/knowns/now-playing/use-audio-player.ts
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0, class-variance-authority@^0.7.1.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/now-playing, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "now-playing" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.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- Default
track.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>- Default
English - Every visible and spoken string, including how the scrubber and volume are read.
- levels
number[] (0 to 1)- Default
static - 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- Default
false - 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.
| Prop | Type | Default | Description |
|---|---|---|---|
| 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 | track.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" | "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> | English | Every visible and spoken string, including how the scrubber and volume are read. |
| levels | number[] (0 to 1) | static | 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 | false | 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
- 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.
- 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.
- 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.
- 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.
- 05Stays headless: you pass the position and the handlers. The optional useAudioPlayer hook wires one audio element to the same props.
- 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
| State | What moves | Timing |
|---|---|---|
| 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
- A video player: use Timeline Scrubber.
- A bare value on a slider: use Slider.
- A status for a running job: use Live Activity.
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" }).