1.1.0 • Published 1 month ago

brgndy-react-wave-form v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

brgndy-react-wave-form

react audio waveform library like soundcloud

화면 기록 2024-04-10 오후 10 42 04

- install

npm install brgndy-react-wave-form

- Usage

import {
  AudioWaveForm,
  AudioWaveFormWrapper,
  PlayOrPauseButton,
} from "brgndy-react-wave-form";
import { buttonClass, waveFormClass, waveFormContainer, icon } from "./App.css";
import { ReactComponent as PlayIcon } from "../src/assets/play.svg";
import { ReactComponent as PauseIcon } from "../src/assets/pause.svg";

const mockMusicData = [
  {
    id: 1,
    src: "/music1.mp3",
  },
  {
    id: 2,
    src: "/music2.mp3",
  },
  {
    id: 3,
    src: "/music3.mp3",
  },
];

function App() {
  return (
    <>
      <AudioWaveFormWrapper>
        {musicData.map((music) => {
          return (
            <div key={music.id} className={waveFormContainer}>
              <PlayOrPauseButton
                src={music.src}
                className=""
                playOrPauseValues={[
                  <PlayIcon className={icon} />,
                  <PauseIcon className={icon} />,
                ]}
              />
              <AudioWaveForm
                waveFormWidth={800}
                barWidth={3}
                barGap={3}
                barVariability={0.5}
                waveFormClassName={waveFormClass}
                audioFileSrc={music.src}
                backgroundTopColor={"red"}
                backgroundBottomColor={"yellow"}
                barTopColor={"black"}
                barBottomColor={"gray"}
              />
            </div>
          );
        })}
      </AudioWaveFormWrapper>
    </>
  );
}

export default App;

AudioWaveForm Component Props

NameDatatypeDefaultDescription
audioFileSrcstring""URL of the music file you want to convert to WaveForm
waveFormClassNamestring""className you want to apply that canvas component.
waveFormWidthnumber500The basic width of the canvas you want to convert. default minimum is 500
waveFromHeightnumber200The basic height of the canvas you want to convert. default minimum is 200
barWidthnumber3Area of ​​the waveform bar you want to convert. default minimum is 3
barGapnumber3gap between waveform bars. default minimum is 3
baseBarHeightnumber0.2Bar height of basic waveform. default minimum is 0.2
barVariabilitynumber0.6Change in height between waveform bars. default minimum is 0.6
backgroundTopColorstring"rgb(92, 92, 92)"Top of the default background color that has not been played yet
backgroundBottomColorstring"rgba(0, 128, 255, 0.7)"The part below the default background color that has not yet been played.
barTopColorstring"rgb(0, 128, 255)"The color of the top part when the song is played
barBottomColorstring"rgba(92, 92, 92, 0.7)"The color of the bottom part when the song is played

PlayOrPause Button Component Props

NameDatatypeDefaultDescription
audioFileSrcstring""src of the music you want to play
classNamestring""className you want to apply that component.
playOrPauseValuesstring, string or React.ReactNode, React.ReactNode"play", "pause"Contents to be included in the play and pause buttons, index 0 is related to play, index 1 is related to pause

Pitfalls

If you want to insert content into a button as SVG, use a conversion tool like svgr to convert it into a component!

Author

License

MIT

1.1.0

1 month ago

1.0.1

1 month ago

1.0.0

1 month ago