Stop a sound I played OnClick from a popup button.

Hi. I am making an app for school. I have a feature where when a button is clicked, a sound is played and a pop up with the option to stop the sound is there. What I want to do is stop the sound I played from a the button in popup. What should I do?

My sound is from JavaScript and Resources with this code:

var audio = new Audio('/App/policesiren.mp3');;

- This is for when I play the sound OnClick.

I need to stop the sound through popup. Thanks for the help in advance.


Hi Aryanne ,

Call pause and set the current time to 0 will stop the sound completely.

function stop() {
    audio.currentTime = 0;

Kind regards,


Hi Aryanne,

In addition to the previously mentioned solution, I have created a sample app which includes the complete solution for the mentioned use-case.

Please refer to the attached .oml file.

see this sample app HTML5AudioPlayerDemo

Let me know, if you face any challanges in understanding the implemenation :)

Hope this helps you!

Kind regards,

Benjith Sam


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.