How to stop HTML5 Audio with JavaScript?

Spread the love

Sometimes, we want to stop HTML5 Audio with JavaScript.

In this article, we’ll look at how to stop HTML5 Audio with JavaScript.

How to stop HTML5 Audio with JavaScript?

To stop HTML5 Audio with JavaScript, we call the pause method.

For instance, we write

sound.pause();
sound.currentTime = 0;

to call pause on the sound audio element.

And then we set its current time to 0 seconds by setting currentTime to 0.

Conclusion

To stop HTML5 Audio with JavaScript, we call the pause method.

Leave a Reply

Your email address will not be published.