0.2.3 • Published 1 year ago

react-audio-kit v0.2.3

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

react-audio-kit

react-audio-kit is a react ui library that contains the web based audio components in a well abstracted form.

Documentation

For well defined documentation and quick hands-on please refer this.

Installation

Install my-project with npm

npm i react-audio-kit

In case, you are using typescript for development, make sure to do following change in your ts config file :

 {
  ...
  "compilerOptions": {
    ...
    "moduleResolution": "node",
    ...
  }
  ...
 }

Components

react-audio-kit comes with the following components :

Playlist manager :

This component provides you a simplest way to handle your playlists and gives you various features like :

  • Pause/ Play audio
  • Seek buffered-audio
  • Loop control
  • Volume control
  • Custom theming

Preview

App Screenshot

Usage

By default, this playlist-manager takes the list of audios to play and internally manages the states of the queue.

import { PlaylistManager } from "react-audio-kit"; // import the components from library
import "react-audio-kit/style.css"; // don't forget to import the styles from the library

export default function Home() {
  return (
    <>
      <PlaylistManager
        theme={{
          baseMediaButtonColor: "#FF69B4",
          hoveredMediaButtonColor: "#FF1493",
          mediaIconColor: "white",
          text: "black",
          loaderColor: "pink",
          shadow: true,
        }}
        audios={audios}
      />
    </>
  );
}
const audios = [
  {
    src: "https://previews.customer.envatousercontent.com/files/247158961/preview.mp3",
    img: undefined,
    subheading: "Subtitle 2",
  },
  {
    src: "https://previews.customer.envatousercontent.com/files/247158961/preview.mp3",
    img: undefined,
    subheading: "Subtitle 1",
  },
];

API

You can customize and use the Playlist Manager using following props :

PropTypeDescriptionDefault
audiosArray<Audio>An array of audio objects to be played.-
getCurrentPlayback(currentPlayback: CurrentPlaybackStateType & { bufferedProgressPercentage: number; }) => voidA callback function that provides the current playback state, including the buffered progress percentage.-
defaultPlaybackCurrentPlaybackStateTypeAn object defining the default playback state.-
preload"auto" \| "metadata" \| "none"Specifies if and how the audio should be preloaded."auto"
themeThemeAn object to customize the appearance of the playlist manager. See the Theme section below for details.-
hideImgbooleanIf true, hides the audio cover image.false
hideAudioNamebooleanIf true, hides the audio name.false
hideLoopIconbooleanIf true, hides the loop icon.false
onClickImage() => voidA callback function triggered when the audio cover image is clicked.-
onClickTitle() => voidA callback function triggered when the audio title is clicked.-
onClickSubtitle() => voidA callback function triggered when the audio subtitle is clicked.-
borderRadiusnumberSets the border radius of the playlist manager.-

Theme

The theme object allows customization of the playlist manager's appearance:

PropertyTypeDescriptionDefault
baseMediaButtonColorstringColor of the media buttons.-
hoveredMediaButtonColorstringColor of the media buttons when hovered.-
mediaIconColorstringColor of the media icons.-
backgroundstringBackground color of the playlist manager.-
textstringText color.-
loaderColorstringColor of the loading spinner.-
baseControlButtonColorstringColor of the control buttons.-
hoveredControlButtonColorstringColor of the control buttons when hovered.-
controlButtonIconColorstringColor of the control button icons.-
shadowbooleanIf true, applies a shadow effect to the playlist manager.false

Audio

PropertyTypeDescription
srcstringAddress for the audio file
imgstringImage source (if any) for the respective image of the song
headingstringTitle of the audio file
subheadingstringSubtitle of the audio file

CurrentPlaybackStateType

PropertyTypeDescription
progressnumberThe current progress of the audio file
isPlayingbooleanWhether the audio is currently playing
volumenumberThe volume level of the audio
activeIndexnumberThe index of the currently active audio in the playlist
loadingbooleanWhether the audio is currently loading
isErrorbooleanWhether there was an error during playback
loopedbooleanWhether the audio is set to loop

Audio Recorder :

This component provides you a simplest way to your own voice in a well abstracted manner :

  • Pause/ Resume/ Start recording
  • Custom theming
  • Getting audio blobs in certain time intervals
  • Loudness indicators
  • Senstivity management

Preview

App Screenshot

App Screenshot

App Screenshot

Usage

By default, audio recorder do not require any props.

import { AudioRecorder } from "react-audio-kit"; // import the components from library
import "react-audio-kit/style.css"; // don't forget to import the styles from the library

export default function Home() {
  return (
    <>
      <AudioRecorder />
    </>
  );
}

The AudioRecorder component is a customizable audio recording utility with various event handlers and configurable properties. This document details the properties that can be passed to the component.

API

Prop NameTypeDescription
getAudioBlobOnStop(audioBlob: Blob) => voidCallback function that receives the final audio Blob when the recording stops.
getCurrentAudioBlobPacket(audioBlob: Blob) => voidCallback function that receives the current audio Blob packets during recording.
handleError(error: any) => voidCallback function that handles any errors that occur during the recording process.
timeSlicenumberOptional parameter specifying the time interval (in milliseconds) at which audio packets are delivered.
onPause() => voidCallback function called when the recording is paused.
onRecord() => voidCallback function called when the recording starts.
onResume() => voidCallback function called when the recording resumes after being paused.
onStop() => voidCallback function called when the recording stops.
sensitivitynumberOptional parameter setting the microphone sensitivity.
colorColorObject to customize the color scheme of the audio recorder UI.

Color

Property NameTypeDescription
basestringBase color for the audio recorder interface.
hoverstringColor used when elements are hovered over.
auorastringAdditional accent color for special UI elements.
iconColorstringColor for icons within the audio recorder interface.

Contributing

Provide guidelines for contributing to the library.

## Contributing

We welcome contributions! Please follow these steps to contribute:

1. Fork the repository.
2. Create a new branch: `git checkout -b my-feature-branch`.
3. Make your changes and commit them: `git commit -m 'Add new feature'`.
4. Push to the branch: `git push origin my-feature-branch`.
5. Submit a pull request.

License

This project is licensed under the MIT License.

0.1.11

1 year ago

0.1.12

1 year ago

0.1.13

1 year ago

0.1.14

1 year ago

0.1.15

1 year ago

0.1.21

1 year ago

0.1.22

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.16

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.18

1 year ago

0.1.19

1 year ago

0.1.9

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago