Vinyl player Pro
One payment, every Pro piece. $9 tomorrow.
Install
npx shadcn@latest add @mu-pro/vinyl-playerPro. Installs with your licence key through the @mu-pro registry; the key comes with Pro. Lands in components/mu/vinyl-player/ with the shared foundation.
Usage
import { VinylPlayer } from "@/components/mu/vinyl-player/VinylPlayer";
// one track, looped: the audio is fetched on the first press
<VinylPlayer src={["/audio/loop.m4a", "/audio/loop.mp3"]} title="Opening" artist="Your Band" cover="/covers/opening.webp" />
// or several
<VinylPlayer
tracks={[
{ title: "Opening", artist: "Your Band", duration: 201, cover: "/covers/opening.webp", src: "/audio/opening.mp3" },
]}
/>Use with an agent Beta
npx shadcn@latest add @mu-pro/uisdk/vinyl-playerOptional. An AI agent in your app can read and set this piece by name, and you can ask before anything it can’t undo. The piece itself doesn’t change; installs with your Pro key, like the piece. Built on UI SDK 0.1.0-beta.23, which is in beta too, so this add-on follows its releases.
Source
How it works
Building with an agent? Hand it a ready prompt for this piece.
Input and reduced motion
- Pointer / touch: play or pause, next track, mute; drag along the groove to seek (the target is 44px tall), or grab the record and turn it (one turn is 12 seconds, backwards included). Next winds the thumb and the time back to 0:00 as the cover turns.
- Keyboard: every control is a button in tab order; the progress line is a range (arrow keys seek).
- Reduced motion: the record doesn't spin, and the cover, label, title and time change at once, with no dial turn or wind.
- Off-screen: the platter and the clock pause while the player is out of view. With a
src, the audio keeps playing and the readout catches up when it returns. - Reduced motion and audio: the music plays, loops and pauses the same; only the platter's turn is dropped.
Props
| Prop | Default | What it does |
|---|---|---|
src | — | one track's audio, in place of tracks: a URL, or a list in order of preference (["/a.m4a", "/a.mp3"]). It starts with the first this browser says it can play (by its extension), and if that one fails to load or decode it tries the next. An empty list is no audio |
title, artist, cover, duration | — | that one track's title, artist, cover and length in seconds (shown until the audio's own length is known) |
tracks | three demo tracks | { title, artist, duration, cover?, src? }, src as above. Without src it keeps time silently; without cover it uses built-in artwork. An empty list is an empty, idle deck: "No tracks" (empty) on built-in artwork, play off, never the demo |
loop | true with a src, false with tracks | at its end a track starts again; false moves on to the next track (and stops at the end of the only one, back at 0:00), as tracks always did |
defaultPlaying | false | start spinning on mount, for a track without src only: audio never starts without a press |
playing | — | controlled: whether it plays; pair it with onPlayingChange. Leave it out and the player keeps its own (defaultPlaying). Set true from your own control, the audio is made and played then (inside your press, where every browser allows it) |
onPlayingChange | — | (playing): called whenever playing changes: a press, the end of the last track, an error, or a browser refusing to play |
track | — | controlled: the track's index; change it to turn the dial to that track. A Next you don't take turns back, so keep it in step from onTrackChange |
defaultTrack | 0 | the track it starts on, when track is left out |
onTrackChange | — | called with the new track index |
time | — | seconds: change it to move the playhead there. A value within half a second of the playhead is taken as an echo and ignored, so you can pass onTimeChange's straight back |
defaultTime | 0 | seconds: where the playhead starts (a saved place), when time is left out |
onTimeChange | — | (seconds): the playhead, about four times a second while it moves and once more where it stops; never per frame |
onTrackEnd | — | (index): called when a track reaches its end without looping |
muted | — | controlled: this player's own mute (the mute key); pair it with onMutedChange |
defaultMuted | false | muted at first, when muted is left out |
onMutedChange | — | (muted): called when the mute key changes it |
onMedia | — | (audio): the <audio> element it makes (on the first press or play), to join to your own Web Audio graph (an equaliser, a meter); null when it lets it go on unmount |
labels | English | { play, pause, next, mute, seek } for the buttons' accessible names (the mute key keeps one name and says its state with aria-pressed; unmute is still accepted and no longer used), error ("Can't play this track"), loading ("Loading", said while the audio buffers) and empty ("No tracks") |
sound | off | key and motor sounds: true, or a volume 0–1 (see Sound) |
className | — | added to the root |
Sound
Off by default. With sound (or a volume, sound={0.5}) the keys are heard: play spins the motor up, pause runs it down, next ticks the bezel round, mute clicks. A track ending or looping on its own is silent, and the motor stops if the player scrolls out of view. These are the player's own key sounds; the music is your src. setMuted(true) from components/mu/sounds.ts silences every cottoncandy item at once.
Licence
Included with Pro: use it in unlimited end products for you and your clients; no reselling as a kit. See the licence.
A music player that really spins. Press play and the record spins up in its well; grab it to scrub, and next turns the cover in its bezel like a dial. The light stays fixed to the room while the record turns under it.
For music, podcasts and playlist pagesMore in Audio & media