Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kyo504/react-native-audio-streaming-player

An audio steaming player for React Native
https://github.com/kyo504/react-native-audio-streaming-player

android audio-player ios react-native streaming-audio

Last synced: 3 months ago
JSON representation

An audio steaming player for React Native

Awesome Lists containing this project

README

        

# react-native-streaming-audio-player [![npm version](https://badge.fury.io/js/react-native-streaming-audio-player.svg)](https://badge.fury.io/js/react-native-streaming-audio-player)

Streaming audio player for iOS + Android

# Features

- Play remote streaming audio source
- Handle audio focus for...
- incoming and outgoing calls
- switching application contexts
- Control audio from notification and lock screen (**Android**)
- Control audio from control center and lock screen (**iOS**)
- Control audio from headsets

# Installation
First, install the library from npm:

```
npm install react-native-streaming-audio-player --save
```

Second, link the native dependencies.

```
react-native link react-native-streaming-audio-player
```

# Running a sample app
In the Example directory:
```
cd Examples
npm install
react-native run-ios or run-android
```

# Usage
```javascript
import Player from 'react-native-streaming-audio-player';

export default class Example extends Component {
constructor(props) {
super(props);
this.state = { currentTime: 0 }
this.onUpdatePosition = this.onUpdatePosition.bind(this);
}

onPlay() {
Player.play(source.url, {
title: source,
artist: source.artist,
album_art_uri: source.arworkUrl,
});
}

onPause() {
Player.pause();
}

render() {
return (


this.onPlay()}
color='red'
/>
this.onPause()}
color='red'
/>


);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});
```

# API and Configuration
Player Control
- play(url: string, metadata: object)
- metadata.title
- metadata.artist
- metadata.album_art_uri
- pause()
- stop()

Callbacks
- onPlaybackStateChanged
- onUpdatePosition

PlaybackState
- NONE
- PLAYING
- BUFFERING
- PAUSED
- STOPPED
- COMPLETED

PlayerAction
- Play
- Pause
- SkipToNext
- SkipToPrevious

# Roadmap
- [ ] Unit tests
- [ ] Clean up

# Contribute

# License
This project is licensed under the MIT License - see the LICENSE file for details