expo-av: Android version crashes on play action, ios works just fine. Audio uri is to a live stream

Please provide the following:

  1. SDK Version: ^46, expo-av:~12.0.4
  2. Platforms(Android/iOS/web/all): ios/Android
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

Hi, I’m fairly new to Expo Development and I’ve found myself in a little pickle. I’m rendering an audio stream functionality in a app i’m building. Followed the guides but the app crashes on Android platform when the play button is hit. iOS works and audio is streamed perfectly. In the code, i’m using “await sound.pauseAsync()” because i found that using “await sound.stopAsync()” was producing a “Seeking interruption” error.

Below is the code sample.

    const [sound, setSound] = useState();
    const [isPlaying, setIsPlaying] = useState(false);

    const onPlaybackStatusUpdate = (status) => {
        setIsPlaying(status.isPlaying);
    }

    const playCurrentSound = async() => {

        if(sound){
            await sound.unloadAsync();
        }

        const { sound : newSound } = await Audio.Sound.createAsync(
            source = {
                uri : "https://radio.canstream.co.uk:9129/live.mp3"
            },
            initialStatus = { shouldPlay : isPlaying },
            onPlaybackStatusUpdate
        )

        setSound(newSound);
    }

    const playSound = async() => {
        setIPlayer(true);
        await sound.playAsync();
    }

    const stopSound = async() => {
        setIPlayer(false);
        await sound.pauseAsync();
    }

    useEffect(() => {

        playCurrentSound();

    }, [])

    useEffect(() => {

        const getNetwork = async () => {
            const res = await Network.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]);

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.