I am building a react native app using expo. I’m using ‘expo-av’.
I’m having trouble having my audio file play in the background.
I have the following but am still not able to get it to work when I switch my app to another app. I don't get any error; the music just stops in my app. Any advice on how to get this to work? Or is there somewhere else my code could be off?
async componentDidMount() {
try {
await Audio.setAudioModeAsync({
allowsRecordingIOS: false,
interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_MIX_WITH_OTHERS,
// interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_DUCK_OTHERS,
playsInSilentModeIOS: true,
interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS,
shouldDuckAndroid: true,
staysActiveInBackground: true,
playThroughEarpieceAndroid: true
})
this.loadAudio();
// this.interval = setInterval(() => this.getStatus(), 1000);
} catch (e) {
console.log(e)
}
}