Skip to content

Type Alias: AudioWaveformViewProps ​

ts
type AudioWaveformViewProps = Omit<ViewProps, "children"> & object;

Props of AudioWaveformView. Standard View props such as style and testID are accepted too (except children). Give the view a height in style, because it has no intrinsic size.

Type Declaration ​

NameTypeDescription
autoPlay?booleanStart playing as soon as the source is ready. Ignored when playing is set. Defaults to false.
barCount?numberFixed number of bars. By default, as many bars as fit the available width. A larger value is capped to what fits.
barGap?numberGap between bars in points (iOS) or dp (Android). Defaults to 2.
barRadius?numberBar corner radius in points (iOS) or dp (Android). Defaults to barWidth / 2.
barWidth?numberBar width in points (iOS) or dp (Android). Defaults to 3.
containerBackgroundColor?ColorValueBackground color of the rounded container. Ignored when showBackground is false. Defaults to '#3478F6'.
containerBorderRadius?numberCorner radius of the container. Ignored when showBackground is false. Defaults to 16.
defaultSpeed?numberInitial playback speed. Applied until the speed is changed by a tap, setSpeed() or the speed prop. Defaults to 1.
initialPositionMs?numberPosition to seek to once the source is ready, in milliseconds. Defaults to 0.
loop?booleanRestart from the beginning when playback ends. onEnd does not fire while looping. Defaults to false.
onEnd()?() => voidFired when playback reaches the end, unless loop is on.
onLoad()?(event) => voidFired once the source is ready to play.
onLoadError()?(event) => voidFired when the source cannot be loaded or played, and when the waveform cannot be decoded (playback may still work in that case).
onPlayerStateChange()?(event) => voidFired with a full snapshot on every state transition: loading, ready, play, pause, speed change, end and error. The same values can arrive more than once, so compare them with your own state.
onSeek()?(event) => voidFired when a scrub gesture ends and after every seekTo() call.
onTimeUpdate()?(event) => voidFired about 30 times per second while playing, and once more at the end. Not fired while the user is scrubbing.
pauseUiUpdatesInBackground?booleanWhile the app is in the background, skip the bar and time label refreshes that run on every progress tick (about 30 per second). The UI snaps to the current position when the app returns. onTimeUpdate keeps firing either way. Defaults to true.
playButtonColor?ColorValueTint of the play / pause icon and of the loading spinner. Defaults to '#FFFFFF'.
playedBarColor?ColorValueColor of the played part of the bars, left of the playhead. Defaults to '#FFFFFF'.
playInBackground?booleanKeep playing when the host app goes to the background. When false, playback pauses on didEnterBackground (iOS) or onHostPause (Android) and does not resume by itself. On iOS, the host app must enable the "Audio, AirPlay, and Picture in Picture" Background Mode (UIBackgroundModes: [audio] in Info.plist). The library sets the shared AVAudioSession category to .playback and activates it, unless the category is already .playback or .playAndRecord. On Android, nothing is required for typical use; add the WAKE_LOCK permission if playback must survive device sleep. Defaults to false.
playing?booleanControlled playing state. When set, the play button and the play(), pause() and toggle() ref methods no longer change playback: a tap fires onPlayerStateChange with the requested isPlaying, and you update this prop.
samples?ReadonlyArray<number>Pre-computed amplitudes in [0, 1], resampled to the bar count. When non-empty, native waveform decoding is skipped. Arrays with values above 1 are normalised against the largest value.
showBackground?booleanWhether to draw the rounded container background. Defaults to true.
showPlayButton?booleanWhether to show the play / pause button. Defaults to true.
showSpeedControl?booleanWhether to show the speed pill. Defaults to true.
showTime?booleanWhether to show the time label. Defaults to true.
sourceAudioWaveformSourceAudio to play. Changing uri stops playback and loads the new source.
speed?numberControlled speed. When set, the speed pill and setSpeed() no longer change the speed: a tap fires onPlayerStateChange with the requested speed, and you update this prop.
speedBackgroundColor?ColorValueBackground color of the speed pill. Defaults to 'rgba(255, 255, 255, 0.25)'.
speedColor?ColorValueText color of the speed pill. Defaults to '#FFFFFF'.
speeds?ReadonlyArray<number>Speeds the pill cycles through on tap. Each tap picks the first value greater than the current speed and wraps to the first value, so list them in ascending order. An empty array falls back to the default. Defaults to [0.5, 1, 1.5, 2].
timeColor?ColorValueText color of the time label. Defaults to '#FFFFFF'.
timeMode?AudioWaveformTimeModeShow elapsed time (count-up) or remaining time (count-down). Defaults to 'count-up'.
unplayedBarColor?ColorValueColor of the part of the bars that has not been played yet. Defaults to 'rgba(255, 255, 255, 0.5)'.

Released under the MIT License.