--- title: HTMLMediaElement.currentTime slug: Web/API/HTMLMediaElement/currentTime translation_of: Web/API/HTMLMediaElement/currentTime ---
HTMLMediaElement.currentTime
属性会以秒为单位返回当前媒体元素的播放时间。设置这个属性会改变媒体元素当前播放位置。该处原文:The HTMLMediaElement.currentTime
property gives the current playback time in seconds. Setting this value seeks the media to the new time.
var cTime = video.currentTime; video.currentTime = 35;
一个 double
双精度浮点数。
var obj = document.createElement('video'); console.log(obj.currentTime);
规范版本 | 状态 | 备注 |
---|---|---|
{{SpecName('HTML WHATWG', "embedded-content.html#dom-media-currenttime", "HTMLMediaElement.currentTime")}} | {{Spec2('HTML WHATWG')}} | No change from {{SpecName('HTML5 W3C')}} |
{{SpecName('HTML5 W3C', "embedded-content-0.html#htmlmediaelement", "HTMLMediaElement.currentTime")}} | {{Spec2('HTML5 W3C')}} | Initial definition. |
{{ CompatibilityTable() }}
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("1.9.1")}} [1] | {{CompatIE("9")}} | {{CompatUnknown}} | {{CompatUnknown}} |
Feature | Android | Edge | Firefox Mobile (Gecko) | Firefox OS (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
HTMLMediaElement.fastSeek()
for another method of setting the time