Audio Player
ProNewA music player on a real audio element: cover, scrubber with buffering, volume, speed, shuffle, repeat and a playlist, in four layouts.
Installation
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
Props
| Prop | Type | Default |
|---|---|---|
| tracks* | AudioTrack[]The playlist. One track makes a single-track player. | — |
| layout | "card" | "stacked" | "bar" | "mini"`card` puts the cover beside the controls and stacks them when narrow, `stacked` is a centred column with a large cover, `bar` is a slim strip for the bottom of a page, and `mini` is a small card for a corner. | "card" |
| playlist | booleanShow the track list. Defaults to on when there is more than one track. | — |
| defaultPlaylistOpen | booleanWhether the track list starts open. | true |
| defaultIndex | numberTrack selected at first. | 0 |
| defaultVolume | numberVolume at first, from 0 to 1. | 1 |
| speeds | number[]Playback rates the speed button steps through. An empty list hides it. | [1, 1.25, 1.5, 2, 0.75] |
| modes | booleanShow the shuffle and repeat buttons. | true |
| volume | booleanShow the volume control. | true |
| loading | booleanDraws a placeholder while the track list is being fetched. | false |
| disabled | booleanTurns every control off. | false |
| label | stringAccessible name of the player. | "Audio player" |
| onTrackChange | (index: number, track: AudioTrack) => voidCalled when another track is selected. | — |
| onPlayingChange | (playing: boolean) => voidCalled when sound starts or stops. | — |
| className | string | — |
Accessibility
- Every control is a native button or range input with a name; the play and mute buttons rename themselves (Play or Pause, Mute or Unmute), and shuffle and the playlist toggle report their state.
- The scrubber is a slider: Left and Right move 5 seconds, Page Up and Page Down 30, Home and End jump to the ends, and it reads as “1 minute 5 seconds of 3 minutes”.
- The current track is marked in the list, a track change is announced politely, and a file that fails to load raises an alert with a Retry button.
- Under reduced motion the equalizer, the buffering spinner and the playlist slide stand still, and progress updates in steps.