API and Development
AudioPlayer from @prepared911/ui-audio-player renders playback controls for emergency and dispatch audio. It supports URL strings, one or more clips with timeline alignment metadata, controlled or uncontrolled time and play state, optional skip controls, mute, and timestamp display modes. Recordings may include sensitive content; the component does not log audio URLs or onPressPlay results—callers must avoid sending those values to analytics or error reporters.
Name | Type | Default | Description |
|---|---|---|---|
|
| — | Audio prop can be either:
1. An array or a single {@link AudioPlayerClip } (pre-loaded elements with absolute
|
|
| — | When set, identifies which player is globally active. When this changes to a different value
than |
|
| — | Optional (for controlled mode). Current playback time in ms (global timeline) |
|
| — | Secondary line under the title (e.g. formatted date/time). |
|
| — | When true, shows the playback-rate dropdown with the default rates [0.75, 1, 1.25, 1.5, 2]. |
|
| — | Optional (for controlled mode). Whether playback is currently active. |
|
| — | Callback when manual scrub occurs |
|
| — | Fired when the user picks a new rate. |
|
| — | Callback when playback state changes |
|
| — | Next-track handler. When provided, shows the next-track button. Also used by shouldAutoPlayNext. |
|
| — | Async callback invoked before playback starts (e.g. fetch signed or access-controlled URLs). If this returns audio URLs/clips, they will replace the current audio prop. If it returns void/undefined, the existing audio prop is used. Do not log return values or errors that embed URLs — they may grant access to sensitive audio. |
|
| — | Previous-track handler. When provided, shows the previous-track button. |
|
| — | Callback for every time change (via natural progression or manual scrub) |
|
| — | Controlled playback speed. When omitted, the player manages rate internally. |
|
| — | This player's ID for coordination with {@link AudioPlayerProps.activePlayerId}. Prefer an opaque identifier; avoid PII in this value. |
|
|
| When true, calls onPressNext automatically when the current audio finishes. |
|
| — | Show time stamps on the player |
|
| — | When set, shows skip backward/forward buttons that jump by this many milliseconds. |
|
|
| Controls how timestamps are displayed when |
|
| — | Target ms between playback time samples (slider, timestamps, |
|
| — | Title shown on the left of the bar (e.g. resource/seat name). Avoid PII you don't want in the DOM. |
|
| — | Layout variant. Omit for the standard inline bar (small icons, no section dividers).
|
Interactive examples and edge cases for this component are in Storybook.
| Name | Type | Default | Description |
|---|---|---|---|
audio | AudioPlayerAudioProp | required | URL string(s), AudioPlayerClip object(s), or arrays of either. Clips may include startedAt / endedAt for transcript alignment. |
activePlayerId | string | null | — | When set with playerId, only one player with matching coordination stays active; others stop. Use opaque IDs. |
playerId | string | — | This instance’s ID for coordination with activePlayerId. |
currentTime | number | — | Controlled mode: current time in ms on the global timeline. |
isPlaying | boolean | — | Controlled mode: whether playback is active. |
minimal | boolean | false | When true, only play/pause (no slider, volume, timestamps). |
showTimeStamps | boolean | — | Show elapsed/total time when not minimal. |
timeDisplayMode | TimeDisplayMode | Combined | Combined: single "current / total" block. Split: current before slider, total after. |
skipInterval | number | — | If set, shows skip back/forward buttons advancing by this many milliseconds. |
onPressPlay | () => Promise<AudioPlayerAudioProp | void> | — | Runs before playback; may return new audio to replace the current prop (e.g. signed URLs). |
onTimeChange | (time: number) => void | — | Fires on playback progress and manual scrub. |
onManualTimeScrub | (time: number) => void | — | Fires when the user scrubs the slider. |
onPlayingChange | (playing: boolean) => void | — | Fires when play/pause state changes. |
Also exported: TimeDisplayMode enum, formatAudioTime, formatDurationHumanReadable, and type guards isAudioClip, isStringArray, isClipArray.
Use minimal for compact rows (e.g. table cells) where scrubbing and volume are not required.
Pair playerId and activePlayerId (often from React state) so opening playback in one list item stops others.
Use onPressPlay to fetch a signed or access-controlled URL when the user starts playback; return the resolved audio value to replace the initial prop.