Skip to content

Props ​

AudioWaveformView accepts the props below plus the standard View props (style, testID, pointerEvents, ...), except children. Only source is required. Sizes are in points on iOS and dp on Android. Color props take any React Native color value, such as '#22D3EE', 'rgba(34, 211, 238, 0.35)' or 'white'.

The generated API reference has the same list with the TypeScript types.

Source and waveform data ​

PropTypeDefaultDescription
source (required){ uri: string }Audio to play: file:// or https:// on both platforms, content:// on Android.
samplesnumber[]Pre-computed amplitudes in [0, 1]. When non-empty, native waveform decoding is skipped.
  • Changing source.uri stops playback and loads the new file. On iOS the waveform goes back to placeholder bars until the new one is decoded. See Platform notes for Android.
  • samples is resampled to the number of bars, so its length does not have to match. Values above 1 are normalised against the largest value. A value of exactly 0 is drawn at placeholder height (20 % of the bar area), because the bars view treats 0 as "not decoded yet"; use a small positive value such as 0.01 for silence. Setting samples back to an empty array starts native decoding. More in Pre-computed samples.

Bars ​

PropTypeDefaultDescription
playedBarColorColorValue#FFFFFFColor of the bars left of the playhead.
unplayedBarColorColorValuergba(255, 255, 255, 0.5)Color of the bars that have not been played yet.
barWidthnumber3Width of each bar.
barGapnumber2Space between bars.
barRadiusnumberbarWidth / 2Corner radius of each bar.
barCountnumberas many as fitFixed number of bars. A value larger than what fits is capped.

The bar under the playhead is split at the exact pixel: played color on the left, unplayed on the right. See Styling for how the bar area is laid out.

Container ​

PropTypeDefaultDescription
containerBackgroundColorColorValue#3478F6Background of the rounded container.
containerBorderRadiusnumber16Corner radius of the container.
showBackgroundbooleantrueDraw the container background. With false, the two props above have no effect.

Play button ​

PropTypeDefaultDescription
showPlayButtonbooleantrueShow the play / pause button.
playButtonColorColorValue#FFFFFFTint of the play / pause icon and of the loading spinner.

Time label ​

PropTypeDefaultDescription
showTimebooleantrueShow the time label.
timeColorColorValue#FFFFFFText color of the time label.
timeMode'count-up' | 'count-down''count-up'Elapsed time, or time remaining.

The label uses the m:ss format, for example 0:07 or 12:30. Minutes are not wrapped into hours.

Speed pill ​

PropTypeDefaultDescription
showSpeedControlbooleantrueShow the speed pill.
speedColorColorValue#FFFFFFText color of the pill.
speedBackgroundColorColorValuergba(255, 255, 255, 0.25)Background of the pill.
speedsnumber[][0.5, 1, 1.5, 2]Speeds the pill cycles through. An empty array falls back to the default.
defaultSpeednumber1Initial speed.

How the pill picks the next speed, and how defaultSpeed interacts with setSpeed(), is explained in Speed and playback.

Playback ​

PropTypeDefaultDescription
autoPlaybooleanfalseStart playing as soon as the source is ready. Ignored when playing is set.
initialPositionMsnumber0Seek to this position (milliseconds) when the source is ready.
loopbooleanfalseStart again from the beginning at the end. onEnd does not fire while looping.

autoPlay and initialPositionMs are read when a source finishes loading. Changing them later affects the next source, not the current one.

Background ​

PropTypeDefaultDescription
playInBackgroundbooleanfalseKeep playing when the app goes to the background. Needs setup on iOS.
pauseUiUpdatesInBackgroundbooleantrueSkip bar and time label refreshes while in the background. onTimeUpdate keeps firing.

See Background playback for the required iOS capability, the optional Android WAKE_LOCK permission and Expo config.

Controlled props ​

PropTypeDefaultDescription
playingbooleanWhen set, the component is controlled: taps on the play button only request a change through onPlayerStateChange.
speednumberWhen set, taps on the speed pill only request a change through onPlayerStateChange.

Leaving them undefined keeps the component uncontrolled. The two are independent, so you can control playing and leave the speed to the pill. See Controlled mode.

Events ​

PropPayload
onLoad{ durationMs }
onLoadError{ message }
onPlayerStateChange{ state, isPlaying, speed, error? }
onTimeUpdate{ currentTimeMs, durationMs }
onSeek{ positionMs }
onEndnone

When each one fires is described in Events.

Released under the MIT License.