Streaming audio player for both iOS and android
Streaming audio player for iOS + Android
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
In the Example directory:
cd Examples
npm install
react-native run-ios or run-android
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 (
<View style={styles.container}>
<View style={{ flexDirection: 'row', alignSelf: 'stretch', justifyContent: 'space-around' }}>
<Button
title='Play'
onPress={() => this.onPlay()}
color='red'
/>
<Button
title='Pause'
onPress={() => this.onPause()}
color='red'
/>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});
Player Control
Callbacks
PlaybackState
PlayerAction
This project is licensed under the MIT License - see the LICENSE file for details