1.0.1 • Published 6 years ago

mui-audio-player v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

MUI Audio Player

Material-UI based Audio Player.

Installation

You can install this library via NPM or YARN.

NPM

npm i mui-audio-player

YARN

yarn add mui-audio-player

Usage

You can check it out the basic usage example. Or:

import React from 'react';
import Grid from '@material-ui/core/Grid';

import pink from "@material-ui/core/colors/pink";
import deepPurple from "@material-ui/core/colors/deepPurple";

import createTheme from "@material-ui/core/styles/createMuiTheme";
import ThemeProvider from "@material-ui/core/styles/MuiThemeProvider";

import { AudioPlayer } from 'mui-audio-player';

const theme = createTheme({
    palette: {
        type: 'light',
        primary: deepPurple,
        secondary: pink
    }
});

export default class App extends React.Component {
    render() {
        return (
            <ThemeProvider theme={theme}>
                <Grid justify="center" alignContent="center" alignItems="center" container style={{ height: "100vh", backgroundColor: deepPurple["500"] }}>
                    <Grid md={4} item />
                    <Grid md={4} item>
                        <AudioPlayer 
                            src="https://s9.converto.io/download-file/zwXZbmwDyWGN7qkqvVPMcQm0pIajpwdE/file.mp3"
                            autoPlay={false}
                            rounded={true}
                            elevation={1}
                            width="100%"
                        />
                    </Grid>
                    <Grid md={4} item />
                </Grid>
            </ThemeProvider>
        );
    }
}

As you can see in the example, this component is pretty well themeable.

Props

These are the properties used by the AudioPlayer component:

PropertiesTypesDefault ValueDescription
srcstringnoneDetermines the url used by the player to load the audio source.
autoPlaybooleanfalseDetermines if the player starts reproducing the audio automatically.
roundedbooleanfalseDetermines if the player container has rounded borders.
elevationnumber1Determines if the player container has box-shadow applied.
widthstring500pxDetermines the width of the player.
heightstring45pxDetermines the height of the player.
classNamesobject{}Determines the classNames to be applied. (*)

(*) classNames is a special property:

PropertiesTypeskeysDescription
classNames.playerstringnoneDetermines the className to be applied to the root container.
classNames.loopIconstringnoneDetermines the classNames to be applied to the loop icon element.
classNames.playIconstringnoneDetermines the classNames to be applied to the play icon element.
classNames.muteIconstringnoneDetermines the classNames to be applied to the mute icon element.
classNames.sliderstringnoneDetermines the classNames to be applied to the slider element.
classNames.trackstringnoneDetermines the classNames to be applied to the track element.
classNames.thumbstringnoneDetermines the classNames to be applied to the thumb element.
classNames.textstringnoneDetermines the classNames to be applied to the text element.

TODO

  • Add volume bar.
  • Add more tests.

Issues

If you found a bug, or you have an answer, or whatever. Please, open an issue. We will do our best to fix it.

Contributing

Of course, if you see something that you want to upgrade from this library, or a bug that needs to be solved, PRs are welcome!

License

Distributed under the MIT license. See LICENSE for more information.