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

@robertio4/material-ui-audio-player

v1.7.0

Published

Audio player for material ui design

Downloads

21

Readme

Material UI Audio Player

Dependency Status NPM version Build Status Package Size

Audio player for material ui design developed with react.js. Requires Material UI 4 version.

Demo: https://werter12.github.io/material-ui-audio-player/

Base

Just add your audio link to src and your ready to go.

import { createMuiTheme, ThemeProvider } from '@material-ui/core';
import AudioPlayer from 'material-ui-audio-player';

const muiTheme = createMuiTheme({});

<ThemeProvider theme={muiTheme}>
  <AudioPlayer src="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3" />
</ThemeProvider>;

Available props

A bunch of props will help to customize component.

import { createMuiTheme, ThemeProvider } from '@material-ui/core';
import AudioPlayer from 'material-ui-audio-player';

const muiTheme = createMuiTheme({});

const src = [
  'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3',
  'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-2.mp3',
];

<ThemeProvider theme={muiTheme}>
  <AudioPlayer
    elevation={1}
    width="100%"
    variation="default"
    spacing={3}
    download={true}
    autoplay={true}
    order="standart"
    preload="auto"
    loop={true}
    src={src}
  />
</ThemeProvider>;

src

Could accept audio link or array of audio links.

  • type: string | array
  • required

width

Corresponds to style property width.

  • default: 100%
  • type: string

variation

Component view variation.

  • default: default
  • options: default, primary, secondary
  • type: string

download

Display download button (icon) with dropdown of available audio tracks for download.

  • default: false
  • type: boolean

volume

Display volume control button (icon).

  • default: true
  • type: boolean

autoplay

Corresponds to HTML audio autoplay attribute.

  • default: false
  • type: boolean

elevation

Shadow depth. Corresponds to elevation prop of Material Ui Paper component.

  • default: 1
  • type: number

rounded

Rounded corners of the container. Corresponds to square prop of Material Ui Paper component.

  • default: false
  • type: boolean

spacing

Spacing for root Grid container. Corresponds to spacing prop of Material Ui Grid component.

  • default: 3 (2 - mobile)
  • type: number

order

Order of Slider and controls buttons.

  • default: standart
  • options: standart, reverse
  • type: string

loop

Display loop button.

  • default: false
  • type: boolean

preload

Corresponds to HTML audio attribute preload.

  • default: auto
  • type: string

onPlayed

This callback triggers when the player started play after pause or initial state

  • type: func

onPaused

This callback triggers when the player paused after the play

  • type: func

onFinished

This callback triggers when the player finish playing

  • type: func

time

This prop helps to customize time displaying. double - means that two timers will be present. single - only one.

  • default: double
  • options: double, single
  • type: string

timePosition

This prop helps to position single timer before (start) or after (end) the slider.

  • default: start
  • options: start, end
  • type: string

useStyles

The attribute for customizing component styles. Accept the result of makeStyles function.

  • type: func

icons

Provide custom icon component from Material-ui icons for specific icon.

  • type: object
  • default:
  const icons = {
    PlayIcon: PlayCircleFilledWhite,
    ReplayIcon: Replay,
    PauseIcon: PauseCircleFilled,
    VolumeUpIcon: VolumeUp,
    VolumeOffIcon: VolumeOff,
    CloseIcon: Close,
  }

displaySlider

Display slider with time.

  • default: true
  • type: boolean

displayCloseButton

Display close button (icon).

  • default: false
  • type: boolean

Customize component styles

import { createMuiTheme, ThemeProvider } from '@material-ui/core';
import AudioPlayer from 'material-ui-audio-player';

const muiTheme = createMuiTheme({});

const useStyles = makeStyles((theme) => {
  return {
    root: {
      [theme.breakpoints.down('sm')]: {
        width: '100%',
      },
    },
    loopIcon: {
      color: '#3f51b5',
      '&.selected': {
        color: '#0921a9',
      },
      '&:hover': {
        color: '#7986cb',
      },
      [theme.breakpoints.down('sm')]: {
        display: 'none',
      },
    },
    playIcon: {
      color: '#f50057',
      '&:hover': {
        color: '#ff4081',
      },
    },
    replayIcon: {
      color: '#e6e600',
    },
    pauseIcon: {
      color: '#0099ff',
    },
    volumeIcon: {
      color: 'rgba(0, 0, 0, 0.54)',
    },
    volumeSlider: {
      color: 'black',
    },
    progressTime: {
      color: 'rgba(0, 0, 0, 0.54)',
    },
    mainSlider: {
      color: '#3f51b5',
      '& .MuiSlider-rail': {
        color: '#7986cb',
      },
      '& .MuiSlider-track': {
        color: '#3f51b5',
      },
      '& .MuiSlider-thumb': {
        color: '#303f9f',
      },
    },
  };
});

<ThemeProvider theme={muiTheme}>
  <AudioPlayer
    width="500px"
    useStyles={useStyles}
    src="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3"
    loop={true}
  />
</ThemeProvider>;

Available classes

  • root
  • playIcon
  • replayIcon
  • pauseIcon
  • volumeIcon
  • muteIcon
  • mainSlider
  • volumeSliderContainer
  • volumeSlider
  • downloadsIcon
  • pauseIcon
  • loopIcon
  • progressTime
  • downloadsContainer
  • downloadsItemLink
  • downloadsItemText