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
| Name | Type | Description |
|---|---|---|
autoPlay? | boolean | Start playing as soon as the source is ready. Ignored when playing is set. Defaults to false. |
barCount? | number | Fixed number of bars. By default, as many bars as fit the available width. A larger value is capped to what fits. |
barGap? | number | Gap between bars in points (iOS) or dp (Android). Defaults to 2. |
barRadius? | number | Bar corner radius in points (iOS) or dp (Android). Defaults to barWidth / 2. |
barWidth? | number | Bar width in points (iOS) or dp (Android). Defaults to 3. |
containerBackgroundColor? | ColorValue | Background color of the rounded container. Ignored when showBackground is false. Defaults to '#3478F6'. |
containerBorderRadius? | number | Corner radius of the container. Ignored when showBackground is false. Defaults to 16. |
defaultSpeed? | number | Initial playback speed. Applied until the speed is changed by a tap, setSpeed() or the speed prop. Defaults to 1. |
initialPositionMs? | number | Position to seek to once the source is ready, in milliseconds. Defaults to 0. |
loop? | boolean | Restart from the beginning when playback ends. onEnd does not fire while looping. Defaults to false. |
onEnd()? | () => void | Fired when playback reaches the end, unless loop is on. |
onLoad()? | (event) => void | Fired once the source is ready to play. |
onLoadError()? | (event) => void | Fired when the source cannot be loaded or played, and when the waveform cannot be decoded (playback may still work in that case). |
onPlayerStateChange()? | (event) => void | Fired 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) => void | Fired when a scrub gesture ends and after every seekTo() call. |
onTimeUpdate()? | (event) => void | Fired about 30 times per second while playing, and once more at the end. Not fired while the user is scrubbing. |
pauseUiUpdatesInBackground? | boolean | While 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? | ColorValue | Tint of the play / pause icon and of the loading spinner. Defaults to '#FFFFFF'. |
playedBarColor? | ColorValue | Color of the played part of the bars, left of the playhead. Defaults to '#FFFFFF'. |
playInBackground? | boolean | Keep 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? | boolean | Controlled 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? | boolean | Whether to draw the rounded container background. Defaults to true. |
showPlayButton? | boolean | Whether to show the play / pause button. Defaults to true. |
showSpeedControl? | boolean | Whether to show the speed pill. Defaults to true. |
showTime? | boolean | Whether to show the time label. Defaults to true. |
source | AudioWaveformSource | Audio to play. Changing uri stops playback and loads the new source. |
speed? | number | Controlled 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? | ColorValue | Background color of the speed pill. Defaults to 'rgba(255, 255, 255, 0.25)'. |
speedColor? | ColorValue | Text 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? | ColorValue | Text color of the time label. Defaults to '#FFFFFF'. |
timeMode? | AudioWaveformTimeMode | Show elapsed time (count-up) or remaining time (count-down). Defaults to 'count-up'. |
unplayedBarColor? | ColorValue | Color of the part of the bars that has not been played yet. Defaults to 'rgba(255, 255, 255, 0.5)'. |