I'm developing a Reactive Native app with audio as one of the main features. Recently, I noticed that playing in silent mode on iOS is no longer working and I can't quite figure out why. I have also tried using expo-av and react-native-track-player and had the same issue.
This is how I initialize the player:
async function initializeAudio(): Promise<void> {
try {
logger.module('audioService').debug('[audioService.ts] Initializing Audio system');
await Audio.setAudioModeAsync({
allowsRecording: false,
playsInSilentMode: true,
shouldPlayInBackground: false,
interruptionModeAndroid: 'duckOthers',
interruptionMode: 'mixWithOthers', // I tried with various options with the same results
});
logger.module('audioService').debug('[audioService.ts] Audio system initialized successfully');
} catch (error) {
logger.module('audioService').error('[audioService.ts] Error initializing Audio system:', error);
throw error;
}
}
What I found is the following:
I have tried using various LLMs to figure out the issue and the closest one to come to somewhat of a solution was Grok 4, but that only got me back to partial audio. Please let me know if you have experienced a similar issue and know a solution for it.
After spending so much time trying to figure out, the issue came down to multiple components competing for AVAudioSession.
In my case, I also had react-native-video playing background video in mute. If you run into a similar situation, make sure to have so that it doesn't conflict with the audio playback. Hope this helps someone coz it took me like 30 hours of experimentation to figure this out.
ignoreSilentSwitch="ignore"
<Video
source={{ uri: media.chat.primary }}
style={styles.characterVideo}
muted={true}
repeat={true}
resizeMode="cover"
rate={1.0}
ignoreSilentSwitch="ignore"
/>