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

apm-react-audio-player

Package Overview
Dependencies
Maintainers
0
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apm-react-audio-player

This is a light react audio player that is wrapped around a HTML5 audio tag, created for use on American Public Media and Minnesota Public Radio's websites.

  • 1.0.22
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
26
increased by333.33%
Maintainers
0
Weekly downloads
 
Created
Source

apm-react-audio-player

This is a light react audio player that is wrapped around a HTML5 audio tag, created for use on American Public Media and Minnesota Public Radio's websites.

The library was designed to add a audio player to a body of a story which will not trigger the static audio player.

Alt text

Table of Contents

Dependencies

Installation

  • NPM
  • YARN

Importing

Usage

[License] (#License)

Dependencies

As of version 1.0.0, this library has no dependencies for usage.

Installation

There are several ways to install APM Player on your site.

NPM

npm install apm-react-audio-player

or to use yarn:

YARN

yarn add apm-react-audio-player

Importing

ES6 Import

The easiest way to include this in modern javascript, assuming you are using something like and Babel, is to use an import statement. The library uses named exports for all modules.

To import the player module:

import { ReactAudioPlayerInner, useAudioPlayer } from 'apm-react-audio-player';

Usage

Props

See the audio tag documentation for detailed explanations of these attributes.

PropTypeDefaultNotes
titleStringempty stringThe title of the audio track
audioSrcStringempty stringThe source URL of the audio file
descriptionStringempty stringThe description of the audio track
audioPlayerRefObjectempty objectA ref object for the audio player
progressBarRefObjectempty objectA ref object for the progress bar
onLoadedMetadataFunction---A function to handle the loadedmetadata event
togglePlayingFunction---A function to toggle the playing state
isPlayingBooleanfalseWhether the audio is currently playing
isMutedBooleanfalseWhether the audio is currently muted
toggleMuteFunction---A function to toggle the mute state
volumeControlFunction---A function to control the volume
currentTimeNumbernullThe current time of the audio track
durationNumbernullThe duration of the audio track
rewindControlFunction---A function to rewind the audio track
forwardControlFunction---A function to fast forward the audio track
changePlayerCurrentTimeFunction---A function to change the current time of the audio track
calculateTimeFunction---A function to calculate the time for the audio track
formatCalculateTimeFunction---A function to format the calculated time
playBtnClassStringempty stringThe CSS class for the play button
customStylesObject---Custom styles for the audio player
customHtmlJSX.Element<></>Custom HTML to be rendered inside the player

Example

import { ReactAudioPlayerInner, useAudioPlayer } from 'apm-react-audio-player';

const Example = () => {

  const audioPlayerRef = React.useRef();
  const progressBarRef = React.useRef();

  const {
    onLoadedMetadata,
    calculateTime,
    volumeControl,
    togglePlaying,
    toggleMute,
    isMuted,
    changePlayerCurrentTime,
    play,
    isPlaying,
    isFinishedPlaying,
    currentTime,
    duration,
    formatCalculateTime,
    rewindControl,
    forwardControl
  } = useAudioPlayer(audioPlayerRef, progressBarRef);

    return (
       <ReactAudioPlayerInner
        title={'MPR NEWS'}
        audioSrc={'https://play.publicradio.org/web/o/minnesota/podcasts/art_hounds/2024/06/26/arthounds_art-hounds-franconia_20240626_64.mp3'}
        description={'description'}
        playBtnClass="player-btn player-btn-playpause js-player-play"
        audioPlayerRef={audioPlayerRef}
        progressBarRef={progressBarRef}
           onLoadedMetadata={onLoadedMetadata}
        play={play}
        isPlaying={isPlaying}
        togglePlaying={togglePlaying}
        isMuted={isMuted}
        currentTime={currentTime}
        duration={duration}
        isAudioFinished={isFinishedPlaying}
        toggleMute={toggleMute}
        volumeCtrl={volumeControl}
        changePlayerCurrentTime={changePlayerCurrentTime}
        rewindControl={rewindControl}
        forwardControl={forwardControl}
        calculateTime={calculateTime}
        formatCalculateTime={formatCalculateTime}
        customHtml={<></>}
    />
  )
}

Publishing

  1. Ensure every merge request and/or change to apm-react-audio-player should always come with an updated version (ex. 1.0.17 to 1.0.18) in the package.json.
  2. Once the changes is on Main branch, locally run:
    1. git pull main
    2. yarn run build or npm run build
    3. yarn publish or npm publish

License

MIT © Phanx091

FAQs

Package last updated on 31 Jul 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