I’ve an app that must be taking part in an audio-file, however the Iphone will not in any respect, not whereas lively and in addition not within the background. This identical app has no downside taking part in that audio on Android tho. I used to be testing this on an put in model of the app, not simply the Expo Go app.
async perform PlaySound() {
logMessage("Enjoying sound...");
await Audio.setAudioModeAsync({
staysActiveInBackground: true,
shouldDuckAndroid: true,
interruptionModeIOS: InterruptionModeIOS.MixWithOthers,
interruptionModeAndroid: InterruptionModeAndroid.DoNotMix,
playThroughEarpieceAndroid: true,
allowsRecordingIOS: true,
playsInSilentModeIOS: true,
});
const { sound: PlaybackObject } = await Audio.Sound.createAsync(
require("../belongings/sounds/chaching.mp3"),
{
shouldPlay: true,
}
);
await PlaybackObject.playAsync();
PlaybackObject.setOnPlaybackStatusUpdate(async (standing) => {
if (standing.isLoaded && !standing.isPlaying) {
await PlaybackObject.unloadAsync();
}
});
}
Dependencies:
"dependencies": {
"@expo/vector-icons": "^14.0.2",
"@react-native-community/cli-platform-android": "^15.1.3",
"@react-navigation/bottom-tabs": "^7.2.0",
"@react-navigation/native": "^7.0.14",
"expo": "~52.0.23",
"expo-audio": "~0.3.1",
"expo-av": "~15.0.1",
"expo-background-fetch": "^13.0.3",
"expo-blur": "~14.0.1",
"expo-constants": "~17.0.3",
"expo-dev-client": "~5.0.8",
"expo-font": "~13.0.2",
"expo-haptics": "~14.0.0",
"expo-linking": "~7.0.3",
"expo-router": "~4.0.15",
"expo-splash-screen": "~0.29.18",
"expo-status-bar": "~2.0.0",
"expo-symbols": "~0.2.0",
"expo-system-ui": "~4.0.6",
"expo-task-manager": "~12.0.3",
"expo-web-browser": "~14.0.1",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-native": "0.76.5",
"react-native-background-actions": "^4.0.1",
"react-native-gesture-handler": "~2.20.2",
"react-native-reanimated": "~3.16.1",
"react-native-safe-area-context": "4.12.0",
"react-native-screens": "~4.4.0",
"react-native-web": "~0.19.13",
"react-native-webview": "13.12.5"
},