I am trying the example from https://docs.expo.dev/versions/latest/sdk/audio/#usage (I just replaced the path of the mp3 file) but my iPhone doesn't play the audio.
Basically, I copied this part (and added the necessary import
s):
const [sound, setSound] = useState();
async function playSound() {
console.log('Loading Sound');
const { sound } = await Audio.Sound.createAsync(
require('./path/to/my/file.mp3'));
setSound(sound);
console.log('Playing Sound');
await sound.playAsync();
}
useEffect(() => {
return sound
? () => {
console.log('Unloading Sound');
sound.unloadAsync();
}
: undefined;
}, [sound]);
It doesn't crash, I just see these logs but hear no sound:
LOG Loading Sound
LOG Playing Sound
Does anyone know how to use it properly?
I checked this similar issue, but the solution doesn't work, and the versions are older: Expo-AV Sound.playAsync() doesn't work with expo-av 9.2.3 and Expo 42.0.3
These are the dependencies that might be relevant:
"@react-navigation/native": "^6.1.7",
"@react-navigation/native-stack": "^6.9.13",
"expo": "~48.0.18",
"expo-av": "~13.2.1",
"react": "18.2.0",
"react-native": "0.71.8",