0

I'm playing sound using react-native-sound and is playing on iOS 12 device but when I check in iOS 13 device is not playing.

here is my code

this.soundPlayer = new Sound(require('../assets/fly.mp3'), '', (error) => {
      console.log(error)
      if (error) {
        console.log('failed to load the sound', error);
        return;
      }
      this.soundPlayer.play()
    })
Akshay I
  • 3,675
  • 1
  • 34
  • 57

2 Answers2

3

if you load sound using require then use

this.soundPlayer = new Sound(require('../assets/fly.mp3'), (error) => {
      console.log(error)
      if (error) {
        console.log('failed to load the sound', error);
        return;
      }
      this.soundPlayer.play()
    })

and when you load sound in the network then use

this.soundPlayer = new Sound(require('../assets/fly.mp3'), '', (error) => {
      console.log(error)
      if (error) {
        console.log('failed to load the sound', error);
        return;
      }
      this.soundPlayer.play()
    })
Akshay I
  • 3,675
  • 1
  • 34
  • 57
0
const notificationSound = new Sound('ring_tone.wav', Sound.MAIN_BUNDLE, (error) => {
    if (error) {
        console.log('failed to load the sound', error);
        return;
    }
});
enter code here

Please use following way in ios notificationSound.play(() => {});

Android notificationSound.play();

Harsha Koshila
  • 141
  • 1
  • 2