HTML Audio & Video
HTML DOM Audio currentTime Property
The currentTime property sets or returns the current playback position, in seconds, of a media element. Reading it tells you where playback is; assigning to it seeks the media to a new position.
Definition and Usage
currentTime is a floating-point number of seconds from the start of the media. It updates continuously during playback and fires the timeupdate event, so it is the value you display in a clock or bind to a seek slider.
Syntax
// Get the current position
let t = mediaElement.currentTime;
// Seek to 30 seconds
mediaElement.currentTime = 30;Assigning a value seeks the media. If the value is outside 0..duration the browser clamps it to the valid range.
Example: skip forward and show time
<video id="myVideo" width="320" controls>
<source src="movie.mp4" type="video/mp4">
</video>
<button onclick="skip()">Skip +10s</button>
<p id="clock">0.0</p>
<script>
const video = document.getElementById("myVideo");
function skip() {
video.currentTime += 10; // jump ahead 10 seconds
}
video.addEventListener("timeupdate", () => {
document.getElementById("clock").textContent =
video.currentTime.toFixed(1);
});
</script>The timeupdate event fires several times per second, keeping the on-screen clock in sync. Adding to currentTime is the standard way to build skip-forward and skip-back buttons.
Seeking to a currentTime that has not been buffered causes the browser to fetch that region first, so playback may briefly pause with a waiting event before resuming.
