Saturday, November 21, 2026
HomeiOS Developmentios - Expo-AV Audio crashing on Android on play

ios – Expo-AV Audio crashing on Android on play

[ad_1]

So I am pretty new to utilizing EXPO and constructing apps. I have been tasked so as to add a media participant to a consumer’s app and the setup I’ve presently works advantageous on iOS on each bodily and emulator gadgets however when the play motion is issued, the app crashes on Android, each bodily and emulator gadgets.

Any assist could be vastly appreciated. Beneath is a snippet of my code.

async operate playSound() {
    console.log(`Loading hyperlink`);
    setIPlayer(true);
    
    const { sound } = await Audio.Sound.createAsync(
        supply = {
            uri : "https://radio.canstream.co.uk:9129/stay.mp3"
        }
    );

    setSound(sound);
    setIsPlaying(true);

    await sound.playAsync();
    
}

async operate stopSound () {
    // await sound.stopAsync();
    await sound.pauseAsync();
    setIPlayer(false);
    setIsPlaying(false); 
}

useEffect(() => {

    const getNetwork = async () => {
        const res = await Community.getNetworkStateAsync();
        if(res.isConnected === false && res.isInternetReachable === false){
            setError(true);
        }
    }

    getNetwork();

    Audio.setAudioModeAsync({
        allowsRecordingIOS: false,
        // interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_DO_NOT_MIX,
        interruptionModeIOS: InterruptionModeIOS.DoNotMix,
        playsInSilentModeIOS: true,
        // interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS,
        interruptionModeAndroid: InterruptionModeAndroid.DuckOthers,
        shouldDuckAndroid: true,
        staysActiveInBackground: true,
        playThroughEarpieceAndroid: false,
        androidImplementation: 'MediaPlayer'
    })

    return sound ? () => {
        sound.unloadAsync(); }
    : undefined;
}, [sound]);

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments