Skip to content
A react-native audio streaming module which works on both iOS & Android
Objective-C Java JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
__tests__ Initial commit Nov 30, 2016
android Upgrade to exoplayer 2.1.1 Apr 7, 2017
ios
.babelrc Initial commit Nov 30, 2016
.buckconfig
.flowconfig Initial commit Nov 30, 2016
.gitignore Initial commit Nov 30, 2016
.watchmanconfig Initial commit Nov 30, 2016
LICENSE Create LICENSE Dec 1, 2016
README.md
index.js common index js Nov 30, 2016
package.json 0.0.9 Apr 18, 2017

README.md

react-native-audio-streamer

A react-native audio streaming module which works on both iOS & Android

iOS streaming is based on DOUAudioStreamer

Android streaming is based on ExoPlayer

Installation

npm install react-native-audio-streamer --save

Then run the following command to link to iOS & Android project

react-native link react-native-audio-streamer

Usage

Basic

import RNAudioStreamer from 'react-native-audio-streamer';

RNAudioStreamer.setUrl('http://lacavewebradio.chickenkiller.com:8000/stream.mp3')
RNAudioStreamer.play()
RNAudioStreamer.pause()
RNAudioStreamer.seekToTime(16) //seconds
RNAudioStreamer.duration((err, duration)=>{
 if(!err) console.log(duration) //seconds
})
RNAudioStreamer.currentTime((err, currentTime)=>{
 if(!err) console.log(currentTime) //seconds
})

// Player Status:
// - PLAYING
// - PAUSED
// - STOPPED
// - FINISHED
// - BUFFERING
// - ERROR
RNAudioStreamer.status((err, status)=>{
 if(!err) console.log(status)
})

Status Change Observer

const {
  DeviceEventEmitter
} = 'react-native'

// Status change observer
componentDidMount() {
    this.subscription = DeviceEventEmitter.addListener('RNAudioStreamerStatusChanged',this._statusChanged.bind(this))
}

// Player Status:
// - PLAYING
// - PAUSED
// - STOPPED
// - FINISHED
// - BUFFERING
// - ERROR
_statusChanged(status) {
  // Your logic
}

Milestones

  • Audio caching
  • Buffering ratio
You can’t perform that action at this time.