npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

translation-manager-audio-player

v1.0.8

Published

A personal audio player for React.js with a few modifications from original

Downloads

32

Readme

react-audioplayer

Build Status npm package

A customizable HTML5 audio player for React.js

Live demo

Features

  • A ready-to-use web audio player for React.js
  • Highly-customizable. You can change theme color, size, functions of this player as you want.
  • Just one single component on the top to use (Almost no learning cost).

Install

  • npm: npm install react-audioplayer --save
  • yarn: yarn add react-audioplayer

Usage

A simple example below.

import Audio from 'react-audioplayer';
// In your render() function:
<Audio
  width={600}
  height={400}
  autoPlay={true}
  playlist={somePlaylist}
/>

Acceptable props

| prop name | value type | default value | isRequired | explanation | | ---------------------- | ---------- | ----------------------- | ------------ | ------------------------------ | | width | number | 400 | no | Width of the component (px) | | height | number | fullPlayer ? 300 : 52 | no | Height of the component (px) | | color | string | "#212121" | no | Theme color of the player | | autoPlay | bool | false | no | Automatically playing when loaded | | volumeOrientationDown | bool | false | no | Make the volume bar head downwards (make it true if the player is positioned at the very top of your webpage) | | fullPlayer | bool | false | no | If true, shows song image given in the playlist. Otherwise just shows the basic player | | comment | bool | false | no | If true, enables comment function. When fullPlayer is false, this is forced to be false. You need to specify onCommentSubmit to handle user input | | onCommentSubmit (text) | Function | null | no | When a user submits a new comment, this function will be invoked and the input content will be passed as an argument | | playlist | array | null | yes | An array of song information objects, see below for details | | style | object | null | no | A normal style object. For example, you can add border or boxShadow to the component. If you also set width or height here, it will override the one you set using width or height API |

playlist prop

playlist is an array of songObj, where

songObj = {
  name: string, // song name
  src: string, // song source address
  img: string, // (optional) song image source address
  comments: an commentObj array // (optional) comments to display of that song
}

commentObj = {
  time: number,
  content: string
}

songObj.img is required when fullPlay = true, songObj.comments is required when comment = true.

Manually control the state of the player in code

To play/pause/skip-to-next/skip-to-previous the player in code, four event listeners are added inside the <Audio /> component.

The name of these events are:

  • audio-play
  • audio-pause
  • audio-skip-to-next
  • audio-skip-to-previous

and a typical example:

class App extends React.Component {
  someMethod() {
    // Some code ...
    // This code can only be able to execute when the audio component is already mounted
    ReactDOM.findDOMNode(this.audioComponent).dispatchEvent(new Event('audio-play'));
  }

  render() {
    return (
      <Audio
        width={600}
        height={300}
        playlist={playlist}
        
        // store a reference of the audio component
        ref={audioComponent => { this.audioComponent = audioComponent; }}
      />
    );
  }
}

As you can see in the example above, there are two steps:

  1. Store the audio component using ref
  2. Get the DOM node (ReactDOM.findDOMNode) and dispatch the event (dispatchEvent)

TODO

  • Loading animation and optimisation

Development

$ git clone https://github.com/wenliangdai/react-audioplayer.git
$ npm install
$ npm start

Then a localhost is open on port 8080.

ChangeLog

Details changes for each release are documented in the release notes or the ChangeLog.md file.

Need help or find a bug?