English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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
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 ‹/›
currentTime attribute sets or returns audio/Current position of video playback (in seconds).
When setting this property, playback will jump to the specified position.
IEFirefoxOperaChromeSafari
All major browsers support the currentTime attribute.
Note:Internet Explorer 8 and earlier versions do not support this attribute.
Set currentTime attribute:
audio|video.currentTime="seconds"
Return currentTime attribute:
audio|video.currentTime
Value | Description |
---|---|
seconds | Indicate audio/Current position of video playback, in seconds. |
Return value: | Numeric value, representing seconds |
---|