Categories
JavaScript Answers

How to set the HTML5 audio position with JavaScript?

Spread the love

Sometimes, we want to set the HTML5 audio position with JavaScript.

In this article, we’ll look at how to set the HTML5 audio position with JavaScript.

How to set the HTML5 audio position with JavaScript?

To set the HTML5 audio position with JavaScript, we can set the currentTime property of the audio element to the seconds we want to go to.

For instance, we write

audio.currentTime = 30;

to set audio.currentTime to 30 seconds to jump to the 30 seconds position.

audio is the audio element that’s playing the clip.

Conclusion

To set the HTML5 audio position with JavaScript, we can set the currentTime property of the audio element to the seconds we want to go to.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *