i have read the docs about playing sounds and audio and it work good
but i want to be able to play/pause the sound like toggle click
when first click performed the sound should be played
when click another one it could pause
and so on
here is my code for doing this but its work just for play
playSound = async () => {
const source = {
uri: 'http://217.66.226.47:8046/;stream.mp3'
};
const sound = new Audio.Sound();
await Audio.setIsEnabledAsync(true);
await sound.loadAsync(source);
if (this.state.playing === true) {
try {
await sound.pauseAsync();
this.setState({ playing: false });
} catch (error) {
console.error(error);
}
} else {
try {
await sound.playAsync();
this.setState({ playing: true });
} catch (error) {
console.error(error);
}
}
};