Prepared Docs

Prepared Docs

⌘K

    Loading navigation…

User

  1. Blocks
  2. Waveform Player
  3. Usage

Waveform player

Usage

Overview

WaveformPlayer from @prepared/ui-waveform-player is the full-fidelity review surface for audio where operators need to see the clip's shape—amplitude over time, silence regions, overlapping speakers—while they listen. It wraps WaveSurfer.js with Prepared styling, an imperative ref, and first-class support for WaveformRegion annotations.

Reach for it when review is the task itself, not a quick sample. Long-form calls, training clips, evidence with annotations, and any workflow that pairs audio with a transcript are its territory.

When to use

Evidence review with regions

Use WaveformPlayer when operators need to mark, label, or jump between segments of a clip—redacted spans, training flags, QA highlights. The region overlay makes the workflow visual; pairing regions with a keyboard-navigable list keeps it accessible.

Transcript-synced playback

When an audio surface sits alongside a transcript (QA review, coaching review), WaveformPlayer synchronizes well: the transcript drives seeks via the imperative ref, and the waveform provides a spatial map of the conversation. Keep both in view; don't stack them behind tabs.

Clips longer than a few minutes

The waveform pays for itself on longer clips, where scrubbing blind in an AudioPlayer is slow and error-prone. Below ~2 minutes, the inline player is usually the better fit.

When not to use

  • Quick sampling from a list. Use AudioPlayer in-row; the waveform is heavy for cells.
  • Background or ambient playback. Don't use this as a media player on a shell route.
  • Video. No video surface; reach for a product-owned video component.
  • Narrow mobile contexts. The waveform needs horizontal room; don't stuff it into phone-sized layouts.

Composition

  • Waveform canvas. Rendered by WaveSurfer; styled to match the product palette.
  • Playback controls. Play/pause and time are optional chrome; if a transcript or external controls drive playback, hide the internal cluster and expose via ref.play / ref.pause.
  • Regions. WaveformRegion[] pass through to the canvas. Each region has an id, start, end, optional label, and color. Keep id stable so downstream code can map back to a domain object.
  • Imperative ref. play, pause, seekTo, getCurrentTime, addRegion, removeRegion, zoomTo—expose whichever actions your product UX needs, but don't hide core controls behind imperative-only paths.

Content guidelines

  • Region labels. Short and scannable ("Caller PII", "Escalation", "Silence"). Label with the purpose of the region, not its metadata.
  • Error copy. WaveSurfer load errors should surface as inline text with a retry—"Waveform unavailable, retry".
  • Loading strings. A spinner alone isn't enough; pair with "Loading waveform" so screen reader users hear context.

Behavior and states

Loading and error

Large clips take time to decode. Render a loading placeholder with accessible text during decode; on error, show an inline message and keep retry reachable. Don't let the canvas crash silently.

Regions

Adding or removing regions should feel lossless. Edits to region boundaries should animate minimally (respect prefers-reduced-motion); selection state changes should update both the canvas overlay and any adjacent region list.

Zoom

When zoom is exposed, anchor it to the playhead or the last selected region, not to the canvas center. Users expect the position they're focused on to stay in view after a zoom change.

External control integration

When transcripts or external buttons drive playback, keep the internal controls hidden to avoid two sources of truth. Let ref.play and ref.pause remain the programmatic surface and hide the cluster via prop.

Best practices

Do

  • Pair the waveform with a transcript or region list when review tasks depend on structure.
  • Keep region IDs stable so they map cleanly back to domain objects.
  • Show loading and error inline—silent failure wastes review time.
  • Anchor zoom to the playhead; users lose their place otherwise.

Don't

  • Don't use WaveformPlayer in dense tables; the canvas is too heavy for row cells.
  • Don't hide core playback behind only the imperative ref.
  • Don't rely on color alone for region meaning—pair with a label.
  • Don't autoplay on mount; long clips start on user action.

Accessibility

Waveform canvases are inherently visual, so paired text paths (transcripts, region lists, time readouts) are required for screen reader users. See the Accessibility page for keyboard seek patterns, region announcements, and fallback paths when the canvas is unavailable.

Related Components

  • Audio player: compact inline playback for sampling clips.
  • Data list: the pattern for exposing region metadata alongside the waveform.
  • Slider: keyboard-accessible seek control when pairing external UI.

Previous

Takeover Page / Accessibility

Next

Waveform Player / API and Development

On this page

Overview
When to use
Evidence review with regions
Transcript-synced playback
Clips longer than a few minutes
When not to use
Composition
Content guidelines
Behavior and states
Loading and error
Regions
Zoom
External control integration
Best practices
Accessibility
Related Components