React-native playing audio from s3 URL using react-native-sound

Viewed 13693

I'm new to react-native and trying to create an audio playing app.

I used react-native-sound to achieve the same. In the documentation, it specifies that I can play the file from a network. But I could not find any docs for the same.

Right now I'm uploading audio files from my ROR backend and adding the file to a local folder inside react. I'm changing that to aws s3.

And the audio file is started like -

var whoosh = new Sound(this.state.soundFile, Sound.MAIN_BUNDLE, (error) => {

where this.state.soundFile is a local file name (string) inside the specified folder.

Is this possible?

2 Answers
import Sound from 'react-native-sound';

const sound = new Sound('http://sounds.com/some-sound', null, (error) => {
  if (error) {
    // do something
  }
  // play when loaded
  sound.play();
});
Related