Skip to content
Eskais UI

Forms

Vinyl Scrubber

A media timeline shown as a photographic suitcase turntable rendered with three.js: the record turns with the position at 33⅓ rpm and a drag on it scratches back and forth, the tonearm follows the track, and the waveform strip under it is UI SDK's slider in seconds. The 3D scene draws in a worker after the controls paint, with a drawn turntable without WebGL. It controls an HTMLMediaElement or works controlled, with seek, play and pause for agents.

Example

Installation

npx shadcn@latest add @eskais/vinyl-scrubber
npm packageslucide-reactthree@0.185.1

Usage

Import
import { VinylScrubber, vinylScrubberLabels } from "@/components/ui/vinyl-scrubber"import { secondsOf, vinylScrubber } from "@/components/ui/vinyl-scrubber-primitive"import {  armAngle,  cameraFovDegrees,  cameraPosition,  cameraTarget,  deckTop,  labelRadius,  pointOnRecord,  projectToStage,  recordCenter,  recordPointAt,  recordRadius,  recordTurn,  secondsPerTurn,} from "@/components/ui/vinyl-scrubber-view"import { useVinylMedia } from "@/components/ui/use-vinyl-media"import { grilleHoles, grooves, tangents } from "@/components/ui/vinyl-scrubber-textures"import { useVinylScene } from "@/components/ui/use-vinyl-scene"import { useVinylClock } from "@/components/ui/use-vinyl-clock"import { useVinylStage } from "@/components/ui/use-vinyl-stage"import { createVinylStage, supportsVinylStage } from "@/components/ui/vinyl-scrubber-stage"import { createTurntableScene } from "@/components/ui/vinyl-scrubber-scene"import { createVinylRunner, serveVinylRunner } from "@/components/ui/vinyl-scrubber-runner"

Reach for it as the timeline of a music or DJ-flavoured player. Pass media for an audio or video element, or value and duration to drive it yourself.

API reference

VinylScrubber

PropTypeDefault
labelrequiredThe accessible name of the player as a whole.string–
mediaThe audio or video it controls: it follows its time and playback, and seeks, plays and pauses it.RefObject<HTMLMediaElement | null>–
valueThe position in seconds. Pass it to control the scrubber.number–
defaultValuenumber0
durationThe length in seconds; read from `media` without it.number–
onValueChangeRuns on every step of a drag, a scratch, a key or an agent's seek.(seconds: number, details: VinylChangeDetails) => void–
playingWhether it plays. Pass it to control playback.boolean–
defaultPlayingbooleanfalse
onPlayingChange(playing: boolean, details: VinylChangeDetails) => void–
peaksLoudness along the track, each from 0 to 1, drawn as the waveform; a plain groove without them.readonly number[]–
stepSeconds per arrow key; 5 by default. Page Up and Page Down move 30.number5
titlePrinted big on the record's label.string–
subtitlePrinted on the label under the title: a side, a track, an artist.string–
disabledbooleanfalse
labelsPartial<VinylScrubberLabels>–
classNameClasses for the root; a function gets the player's state.string | ((state: VinylScrubberState) => string | undefined)–
onPaintCalled with each paint's duration in ms, for measuring.(milliseconds: number) => void–

Other exports

vinylScrubberLabelssecondsOfvinylScrubberarmAnglecameraFovDegreescameraPositioncameraTargetdeckToplabelRadiuspointOnRecordprojectToStagerecordCenterrecordPointAtrecordRadiusrecordTurnsecondsPerTurnuseVinylMediagrilleHolesgroovestangentsuseVinylSceneuseVinylClockuseVinylStagecreateVinylStagesupportsVinylStagecreateTurntableScenecreateVinylRunnerserveVinylRunnertype VinylChangeDetailstype VinylScrubberLabelstype VinylScrubberPropstype VinylScrubberStatetype VinylPlaytype VinylScrubberOptionstype VinylSeektype Vectortype MediaReadingtype DeckInputtype VinylStagetype LabelImagetype StageSizetype TurntableScenetype DeckState

Accessibility

  • The waveform strip is a slider in seconds: arrows step by the step (5 s), Page Up and Page Down 30 s, Home and End the ends, and it reads as the time of the duration.
  • Play is a toggle that stays pressed while it plays, with a tooltip.
  • Under reduced motion the record doesn't spin between time updates.
  • The 3D turntable is a picture hidden from assistive tech; the slider and the toggle carry everything it shows.

Agent actions

Agents find it by its label and call seek (seconds or "m:ss"), play and pause; a seek past the end, or before the duration is known, fails the step with why.

Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.