0
[Not solved yet] NotAllowedError: play() can be initiated only by user gesture //ontouchstart used
Hi everyone, I'm trying to create a button which produces a sound when touched. I want the sound to last until I keep my finger on the button. To achieve that, I used the functions "ontouchstart" and "ontouchend" to initiate audio.play(), but that resulted in an Error: "play() can be initiated only by user gesture". The function .play() can be initiated only by "onclick"? Why "ontouchstart" doesn't work to initiate play()? Here is a simple example of the problem: https://code.sololearn.com/WUOzYfFo23aP/?ref=app You can easily check that the audio will be played only if you change "ontouchstart" with "onclick". I hope this question is clear, this is my first one on SoloLearn... thank you for your help!
1 Respuesta
0
Could it be a bug of SoloLearn's code editor, or is it my misunderstanding of "ontouchstart"? Thank you in advance for any of your answers.