0.0.2 • Published 1 year ago

react-rhythm-play v0.0.2

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

React Rhythm Play

Visualization of music playback on react. Provides an audio player component with audio visualization.

Demo

Installation

npm install react-rhythm-play -D

Usage

Dafault:

screenshot

import { AudioWave } from "react-rhythm-play";
import audio from "./audio_path.ogg";

const Component = () => {
  return <AudioWave audioSource={audio} height={400} width={750} />;
};

export default Component;

With custom audio bar:

screenshot

import { useRef } from "react";
import { AudioWave, useAudio } from "react-rhythm-play";
import audio from "./audio_path.ogg";

const Component = () => {
  const audioWaveRef = useRef();

  const { togglePlayPause } = useAudio(audioWaveRef);

  return (
    <div>
      <AudioWave
        ref={audioWaveRef}
        height={400}
        width={750}
        audioSource={audio}
        isCustomAudioBar
      />
      <button onClick={togglePlayPause}>play/pause</button>
    </div>
  );
};

export default Component;

Props

PropTypeDefaultRequiredDescription
colorstring"#8683bd"Audio wave form initial color
progressColorstringAudio wave form progress color
progressGradientStartColorstring"#411bf4"Audio wave form progress gradient start color
progressGradientEndColorstring"#a543a0"Audio wave form progress gradient end color
widthnumber100%Audio wave form width
heightnumbertrueAudio wave form height
audioSourcestringtrueAudio source
loadingComponentReact.ReactNodeRender component while loading
errorComponentReact.ReactNodeRender component when throw error
isCustomAudioBarbooleanfalseShow/hide audio bar
onPlayAudio() => voidCalled on play audio
onPauseAudio() => voidCalled on pause audio
onAudioRewind(sec: number) => voidCalled on audio rewind
onMuteAudio() => voidCalled on mute audio
onChangeVolume(volume: VolumeRangeType) => voidCalled on change audio volume