1.0.12 • Published 8 months ago

react-native-audio-player-button v1.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

React Native Audio Player Button is a custom button with an icon for playing audio. The user is able to use this button as many as they want on the same screen without having the issue of overlapping playing audio.

Support

iOS & Android

Installation

npm install react-native-audio-player-button

Installing dependencies

npm install react-native-vector-icons react-native-sound

Usage

import AudioPlayerButton from 'react-native-audio-player-button';
import FAIcon from 'react-native-vector-icons/FontAwesome';

//...
const [playingUuid, setPlayingUuid] = React.useState(null);

<AudioPlayerButton
  audio={require('sample.mp3')}
  itemUuid='abcdefg'
  isSpeakerIcon={true}
  rippled={true}
  iconPrimaryColor='#0088ff'
  iconSecondaryColor='#5da297'
  playingUuid={playingUuid}
  updatePlayingUuid={(uuid) => setPlayingUuid(uuid)}
  containerStyle={{marginTop: 16}}
  customIcon={<FAIcon/>}
  customIconSet={{play: 'play-circle', pause: 'pause-circle', mute: 'repeat'}}
/>

Properties

Basic

PropDefaultTypeOptionalDescription
audionull.mp3falseThe audio file that will be playing
itemUuidnullstringfalseA unique uuid of the audio or the uuid of the button (to prevent playing audio overlap)
playingUuidnullstringfalseThe uuid of the audio that is currently playing
isSpeakerIconfalsebooleantrueIf true, it will show a speaker icon. If false, it will show a normal play icon
buttonColor'#ffffff'stringtrueThe color of the button
buttonHeight48 or 56numbertrueHeight of the button
buttonWidth48 or 56numbertrueWidth of the button
rippledfalsebooleantrueIf true, it will show a ripple animation while playing the audio
rippleColor'#000000'stringtrueColor of the ripple animation
rippleHeight48 or 56numbertrueThe height of the ripple animation
rippleWidth48 or 56numbertrueThe width of the ripple animation
rippleRadius48 or 56numbertrueThe radius of the ripple animation (higher radius makes the ripple appear in a round shape)
iconSize24 or 26numbertrueThe size of the icons (play and pause icon)
iconPrimaryColor'#000000'stringtrueThe color of the icon before playing the audio
iconSecondaryColor'#808080'stringtrueThe color of the icon while playing the audio
playingUuid''stringfalseThe uuid of the playing audio component (to prevent playing audio overlap each other)
hasShadowfalsebooleantrueThe shadow of the button (Android only)
allowPausefalsebooleantrueAllow to pause the audio when toggle the button
isFromAppBundlefalsebooleanfalseSet to true to play the audio that is stored in the app bundle (ex: the downloaded audio)
rippleScaleSize'medium'stringtrueThe scale size of the ripple animation while the audio is playing
  • The default width, height of the button and ripple animation will be 56dp and 48dp for the low pixel devices

Custom styles

PropDefaultTypeOptionalDescription
containerStyle{...}styletrueStyle of the button and ripple animation container
buttonStyle{...}styletrueStyle of the button
iconStyle{...}styletrueStyle of the audio icons (play and pause icon)
rippleStyle{...}styletrueStyle of the ripple animation
customNotPlayingIconStyle{...}styletrueStyle of the audio icon when is not playing
customPlayingIconStyle{...}styletrueStyle of the audio icon while playing

Custom components

PropDefaultTypeOptionalDescription
customIcon{...}comptrueCustom audio icon component
customIconSet{{play: '', pause: '', mute: ''}}hashtrueA hash of the custom icon names

Child components

<AudioPlayerButton {...props}>
  <child components/>
</AudioPlayerButton>
  • play: The icon that will be shown when the audio is not playing
  • pause: The icon that will be shown while the audio is playing
  • mute: The icon that will be shown when there is no audio file
  • Default icon types of the button:
    • Speaker icon use Ionicons
    • Normal play icon use Feather icons

Events

PropDefaultTypeOptionalDescription
updatePlayingUuid{...}eventfalseOn press the button, to update the uuid of the playing item
onPress{...}eventtrueEvent when pressing the button

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.


Made with create-react-native-library

1.0.11

9 months ago

1.0.10

9 months ago

1.0.12

8 months ago

1.0.9

12 months ago

1.0.8

12 months ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago