How to Properly Use Audio

I am trying to use the Audio through the code snippets provided in documentation (https://docs.expo.io/versions/latest/sdk/audio/).

  componentDidMount() {
    this.playSound();
  }

  async playSound() {
    const soundObject = new Audio.Sound();
      await soundObject.loadAsync(require('./assets/sounds/hello.mp3'));
      soundObject.setPositionAsync(0);
      await soundObject.playAsync();
      // Your sound is playing!
      // NO IT IS NOT PLAYING :-(
  }

The simplest possible snack that I tried is here: https://snack.expo.io/@mehmetkaplan/f3e2dc

The problem is no matter what I do, I can not hear the sound.

Can it be related with the documentation or the expo application or - most possibly - something crucial I am missing?

Thanks in advance…

Hi @mehmetkaplan- that snack works for me. What device are you running it on? (Also, make sure your device isn’t on silent! :smile:)

1 Like

That is embarrassing :face_with_hand_over_mouth::disappointed_relieved: but you are totally right.
I had tried with two different phones unluckily both were in silent mode.

Thanks you…

Haha, I only know because I’ve been there. Glad it was a simple fix

1 Like