Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 28480

React Native Expo audio player error - Player does not exist

$
0
0

I'm using react native expo audio in my app, I use createAsync to load the audio in the player but sometimes i get Player doesn't exist error and sometimes it works fine. I'm unable to debug the error. I've also tried expo loadAsync to create and load the audio, it also produces the same error. Heres my code...

    componentWillMount(){
        const audioFileLocation = audioFile;
        const source = audioFileLocation;
        const { sound } = await Audio.Sound.createAsync(
            source,
            {
                progressUpdateIntervalMillis: 1000,
                shouldPlay: false,
                isLooping: false,
            },
            onPlaybackStatusUpdate,
        );
        return sound;Ï
    }

export const playAndPauseSound = async (playbackStatus, playbackInstance) => {
    if (playbackStatus.isPlaying) {
        await playbackInstance.pauseAsync();
    } else {
        if (playbackStatus.positionMillis === playbackStatus.durationMillis) {
            return playbackInstance.replayAsync();
        } else {
            return playbackInstance.playAsync();
        }
    }
}

Viewing all articles
Browse latest Browse all 28480

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>