Sometimes, we want to set HTML5 audio position with JavaScript.
In this article, we’ll look at how to set HTML5 audio position with JavaScript.
How to set HTML5 audio position with JavaScript?
To set HTML5 audio position with JavaScript, we can set the currentTime
property.
For instance, we write
const element = document.getElementById("audioPlayer");
element.play();
element.currentTime = 226;
to get the audio element with getElementById
.
And then we set the currentTime
property to the position of the audio in seconds.
Conclusion
To set HTML5 audio position with JavaScript, we can set the currentTime
property.