LYL-Radio / react-native-audio

Audio library for react native

Home Page:https://www.npmjs.com/package/@lyl-radio/react-native-audio

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-native-audio

React Native audio library with background capabilities on both iOS and Android.

Installation

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"

Usage

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.

Hooks

A simple set of hooks allows you to respond to player events.

usePlaybackState

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.

usePlayerDuration

The player duration hook will update your function component when the player has updated the playing track duration in seconds.

usePlayerProgress

Updates your function component as the player progress. The progress value is expressed in seconds.

Contributing

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

License

MIT

About

Audio library for react native

https://www.npmjs.com/package/@lyl-radio/react-native-audio

License:MIT License


Languages

Language:Swift 34.1%Language:Kotlin 31.0%Language:TypeScript 22.6%Language:JavaScript 5.6%Language:Ruby 4.2%Language:Objective-C 2.5%