Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sina_byn/re-audio

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sina_byn/re-audio

A highly customizable React audio player library with support for modern web audio features and seamless integration into any React application.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
decreased by-29.41%
Maintainers
1
Weekly downloads
 
Created
Source

re-audio NPM version NPM monthly downloads NPM total downloads

Creating audio players in React has never been easier

re-audio banner

Make sure to visit the documentation website at https://sina-byn.github.io/re-audio/

  • Built with TypeScript for seamless integration in TypeScript projects
  • Fully customizable with a headless component architecture
  • Developer-friendly with an intuitive API
  • Includes custom React hooks for easily creating audio visualizers

Installation

npm i --save @sina_byn/re-audio

Usage

// * AudioPlayer.tsx

import { Audio, formatTime } from '@sina_byn/re-audio';

// * components
import PlayBackControls from './PlayBackControls';

const AudioPlayer = () => {
  return () => (
    <Audio
      playlist={[
        { id: 1, src: '/audio/1.mp3', name: 'for-her-chill' },
        { id: 2, src: '/audio/2.mp3', name: 'trap-type-beat-rap-instrumental-riff' },
        { id: 3, src: '/audio/3.mp3', name: 'whip-afro-dancehall' },
      ]}
    >
      {audioContext => (
        <div>
          <header style={{ display: 'flex', gap: '1rem' }}>
            <span>{formatTime(audioContext.currentTime)}</span>
            <span>/</span>
            <span>{formatTime(audioContext.duration)}</span>
          </header>

          <footer style={{ display: 'flex', gap: '1rem' }}>
            <PlayBackControls />
          </footer>
        </div>
      )}
    </Audio>
  );
};

export default AudioPlayer;
// * PlayBackControls.tsx

import { useAudio } from '@sina_byn/re-audio';

const PlayBackControls = () => {
  const { playing, togglePlay, prevTrack, nextTrack } = useAudio();

  return (
    <>
      <button type='button' onClick={prevTrack}>
        prev
      </button>

      <button type='button' onClick={togglePlay}>
        {playing ? 'pause' : 'play'}
      </button>

      <button type='button' onClick={nextTrack}>
        next
      </button>
    </>
  );
};

export default PlayBackControls;

Keywords

FAQs

Package last updated on 09 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc