react-native-audio-streaming icon indicating copy to clipboard operation
react-native-audio-streaming copied to clipboard

Is there a way to retrieve the ReactNativeAudioStreaming play status?

Open ardboer opened this issue 7 years ago • 1 comments

Cool module but I also like to know the status of the player to know if it is loading, playing or stopped.

ardboer avatar Dec 27 '17 09:12 ardboer

You can do it as such:

this.intervalIdStreamState = setInterval(() => {
  ReactNativeAudioStreaming.getStatus((error, info) => {
    let streamStatus
    if (error) {
      streamStatus = 'error'
      console.log(error);
    } else {
      streamStatus = info.status.toLowerCase()
    }
    if (this.state.streamStatus !== streamStatus) {
      console.log('streamStatus stream CHANGED', streamStatus)
      this.setState({ streamStatus }, () => this.onStreamStateChange(streamStatus))
    }
  })
}, 200)

graphee-gabriel avatar Mar 22 '18 00:03 graphee-gabriel