I want to play a sound with a button. If the sound is already playing I also want the button to work, stopping, rewinding and playing again the sound, but it doesn't seem to work. Here is my function.
export function PlaySound(audioRef){
audioRef.stop(()=>{
audioRef.play((success)=>{if(success)console.log('sound played !')})
})
}
}
It plays the sound, and plays it again when I press again after the sound has finished. But If I press while the sound is playing, no sound is played, and the console stille shows 'sound played !'
Why is that ? Any solution ?
Hi !
I want to play a sound with a button. If the sound is already playing I also want the button to work, stopping, rewinding and playing again the sound, but it doesn't seem to work. Here is my function.
It plays the sound, and plays it again when I press again after the sound has finished. But If I press while the sound is playing, no sound is played, and the console stille shows 'sound played !' Why is that ? Any solution ?