HTMLMediaElement
接口的
currentTime
property specifies the current playback time in seconds.
Changing the value of
currentTime
this value seeks the media to the new time.
var currentTime = htmlMediaElement.currentTime; htmlMediaElement.currentTime = 35;
A double-precision floating-point value indicating the current playback time in seconds.
If the media is not yet playing, the value of
currentTime
indicates the time position within the media at which playback will begin once the
play()
方法被调用。
设置
currentTime
to a new value seeks the media to the given time, if the media is available.
For media without a known duration—such as media being streamed live—it's possible that the browser may not be able to obtain parts of the media that have expired from the media buffer. Also, media whose timeline doesn't begin at 0 seconds cannot be seeked to a time before its timeline's earliest time.
The length of the media in seconds can be determined using the
duration
特性。
var video = document.createElement('video');
console.log(video.currentTime);
To offer protection against timing attacks and fingerprinting, browsers may round or otherwise adjust the value returned by
currentTime
.
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 实时标准
The definition of 'HTMLMediaElement.currentTime' in that specification. |
实时标准 | 无变化自 HTML5 |
|
HTML5
The definition of 'HTMLMediaElement.currentTime' in that specification. |
推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
currentTime
|
Chrome 43 | Edge 12 | Firefox 3.5 | IE 9 | Opera Yes | Safari 6 | WebView Android 43 | Chrome Android 43 | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android 4.0 |
完整支持
HTMLMediaElement
.
HTMLMediaElement.fastSeek()
: Another way to set the time
HTMLMediaElement.duration
: The duration of the media in seconds
HTMLMediaElement
BeforeUnloadEvent
DOMStringMap
ErrorEvent
GlobalEventHandlers
HTMLAnchorElement
HTMLAreaElement
HTMLAudioElement
HTMLBRElement
HTMLBaseElement
HTMLBaseFontElement
HTMLBodyElement
HTMLButtonElement
HTMLCanvasElement
HTMLContentElement
HTMLDListElement
HTMLDataElement
HTMLDataListElement
HTMLDialogElement
HTMLDivElement
HTMLDocument
HTMLElement
HTMLEmbedElement
HTMLFieldSetElement
HTMLFormControlsCollection
HTMLFormElement
HTMLFrameSetElement
HTMLHRElement
HTMLHeadElement
HTMLHeadingElement
HTMLHtmlElement
HTMLIFrameElement
HTMLImageElement
HTMLInputElement
HTMLIsIndexElement
HTMLKeygenElement
HTMLLIElement
HTMLLabelElement
HTMLLegendElement
HTMLLinkElement
HTMLMapElement
HTMLMetaElement
HTMLMeterElement
HTMLModElement
HTMLOListElement
HTMLObjectElement
HTMLOptGroupElement
HTMLOptionElement
HTMLOptionsCollection
HTMLOutputElement
HTMLParagraphElement
HTMLParamElement
HTMLPictureElement
HTMLPreElement
HTMLProgressElement
HTMLQuoteElement
HTMLScriptElement
HTMLSelectElement
HTMLShadowElement
HTMLSourceElement
HTMLSpanElement
HTMLStyleElement
HTMLTableCaptionElement
HTMLTableCellElement
HTMLTableColElement
HTMLTableDataCellElement
HTMLTableElement
HTMLTableHeaderCellElement
HTMLTableRowElement
HTMLTableSectionElement
HTMLTemplateElement
HTMLTextAreaElement
HTMLTimeElement
HTMLTitleElement
HTMLTrackElement
HTMLUListElement
HTMLUnknownElement
HTMLVideoElement
HashChangeEvent
历史
ImageData
定位
MessageChannel
MessageEvent
MessagePort
Navigator
NavigatorGeolocation
NavigatorID
NavigatorLanguage
NavigatorOnLine
NavigatorPlugins
PageTransitionEvent
Plugin
PluginArray
PopStateEvent
PortCollection
PromiseRejectionEvent
RadioNodeList
Transferable
ValidityState
Window
WindowBase64
WindowEventHandlers
WindowTimers