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();
}
}
}