Import a sound and play it using Audio expo-av
Before teaching you how to do that, I had to learn this myself, because the documentation doens’t contain this specific situation very clearly, to play some audio that you recently imported.
First - You have to install the dependecies
$ expo install expo-av
$ expo install expo-document-picker
Second - Import inside your project

Third - Then create a var to store the imported audio

Fourth - Inside the return page code, create a button to import the audio

Fifth - Create a function to import an audio

Sixth - Update the button ‘onPress’

Seventh - Create a button to play the imported audio

Eighth - Create the function to play the audio when the user clicks on the button

Nineth - Now just update the button ‘onPress’

Tenth - Now have Fun!!! Here are the full code:

And here are the full code in snack.expo.io for you test it or copy it
Thanks for seeing this! I hope this article helped you!