React Native audio library with background capabilities on both iOS and Android.
Install from the command line:
$ npm install @lyl-radio/react-native-audio@0.8.2
Install via package.json:
"@lyl-radio/react-native-audio": "0.8.2"
The Audio
takes a Source
object as input.
import Audio from "@lyl-radio/react-native-audio"
Audio.play({ uri: 'https://your/content.mp3' })
The Source
includes metadata to setup the Now Playing Info on iOS' Control Center and the Media Controls on Android.
type Source = {
uri: string
title: string
artwork?: string
album?: string
artist?: string
albumArtist?: string
}
See example for more details.
A simple set of hooks allows you to respond to player events.
The player state hook will return PlaybackState on change events allowing you to update your stateful function component when the player starts playing
, buffering
or on paused
or ended
.
The player duration hook will update your function component when the player has updated the playing track duration in seconds.
Updates your function component as the player progress. The progress value is expressed in seconds.
See the contributing guide to learn how to contribute to the repository and the development workflow.