visualize a waveform of an audio file
npm install react-audio-waveshell
if you prefer npm
npm install react-audio-waveif you prefer yarn
yarn add react-audio-waveif you prefer pnpm
pnpm add react-audio-wave
`Example
`tsx
const AudioPlayer = () => {
{/ ... /}
return (
{/ ... /}
supportPlaybackRate
className="audio-wave-container"
waveHeight={waveHeight}
colors={colors}
audioSrc={audioSrc}
onChangeLoadState={onChangeLoadState}
onCurrentTimeChange={onCurrentTimeChange}
onPlayEnded={onPlayEnded}
placeholder={Placeholder}
/>
);
};
`
Full code of the example, refer to the exampleProps
For the interface definition, please refer to the API documentation
`tsx
interface ReactAudioWaveProps {
waveHeight: number;
colors: Wavecolors;
audioSrc: string;
placeholder: PropsWithChildren;
emptyElement?: ReactElement;
barGap?: number;
barWidth?: number;
progressStyle?: CSSProperties;
supportPlaybackRate?: boolean;
mono?: boolean;
progressCursorVisible?: boolean;
cursorVisible?: boolean;
cursorTimeConfig?: CursorTimeConfig;
className?: string;
timeFormat?: (seconds: number) => string;
onChangeLoadState?: (state: LoadStateEnum, duration?: number) => void;
onCurrentTimeChange?: (current: number) => void;
onWaveSizeChange?: (size: Size) => void;
onPlayEnded?: () => void;
renderErrorElement?: (error?: string) => ReactElement;
}
``