English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag大全

HTML Audio/Video DOM currentTime property

The currentTime property returns the playback time of the current media element in seconds. Setting this property changes the current playback position of the media element.

 HTML Audio/Video DOM Reference Manual

Online Example

Set the time position to 5 seconds:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8>
<title>HTML Audio/video currentTime property usage-Basic Tutorial(oldtoolbag.com)</title>/<title>
</<head>
<body>
<button onclick="getCurTime()" type="button">Get the current time position</button>
<button onclick="setCurTime()" type="button">Set the time position to 5 seconds</button>
<br> 
<video id="video1" controls="controls">
  <source src="movie.mp4" type="video/mp4>
  <source src="movie.ogg" type="video/ogg">
  Your browser does not support HTML5 video tag.
</video>
<script>
myVid = document.getElementById("video"1;
function getCurTime()
{ 
  alert(myVid.currentTime);
} 
function setCurTime()}
{ 
  myVid.currentTime=5;
} 
</script> 
</body>
</html>
Test to see ‹/›

Definition and Usage

currentTime attribute sets or returns audio/Current position of video playback (in seconds).
When setting this property, playback will jump to the specified position.

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the currentTime attribute.

Note:Internet Explorer 8 and earlier versions do not support this attribute.

Syntax

Set currentTime attribute:

audio|video.currentTime="seconds"

Return currentTime attribute:

audio|video.currentTime

Attribute value

ValueDescription
secondsIndicate audio/Current position of video playback, in seconds.

Technical Details

Return value:Numeric value, representing seconds
 HTML Audio/Video DOM Reference Manual