Hi there!
I am currently using react-native-sound for audio playback. Actually, I have a super simple use case with some static sounds that need to be played on press.
As described in react-native-sound docs I have added all my audio files to the native projects so they’re bundled (android/app/src/main/res/raw
for android and on root level for iOS). When loading the files im my code I can use the absolute path like for example createSoundFunction('my_sound.mp3')
. No need for relative paths within the JS. I think this approach is pretty smart so I would like it in expo-av as well. Unfortunately I haven’t seen anything about this approach in the docs and it seems not to work with expo-av.
I would expect await Audio.Sound.createAsync(require('my_sound.mp3'))
to work but it throws an error: my_sound.mp3 could not be found within the project
. In addition to that I need dynamic file names like e.g. await Audio.Sound.createAsync(require(
${soundName}.mp3))
. This will not work with the require calls inline. So basically I need something like await Audio.Sound.createAsync('my_sound.mp3')
where the file is in androids res/raw or iOS root folder.
Does someone have a hint for me? Thanks!