Expo – Audio wird auf IOS nicht abgespielt

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Expo – Audio wird auf IOS nicht abgespielt

by Guest » 19 Jan 2025, 00:04

Ich habe eine App, die eine Audiodatei abspielen sollte, aber das iPhone spielt das überhaupt nicht ab, weder im aktiven Zustand noch im Hintergrund. Dieselbe App hat jedoch kein Problem damit, dieses Audio auf Android abzuspielen. Ich habe dies mit einer installierten Version der App getestet, nicht nur mit der Expo Go-App.

Code: Select all

async function PlaySound() {
logMessage("Playing 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("../assets/sounds/chaching.mp3"),
{
shouldPlay: true,
}
);

await PlaybackObject.playAsync();
PlaybackObject.setOnPlaybackStatusUpdate(async (status) => {
if (status.isLoaded && !status.isPlaying) {
await PlaybackObject.unloadAsync();
}
});
}
Abhängigkeiten:

Code: Select all

"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"
},

Top