Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. HTMLMediaElement
  4. currentTime

HTMLMediaElement: currentTime property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

TheHTMLMediaElement interface'scurrentTime property specifies the current playback timein seconds.

Changing the value ofcurrentTime seeks the media tothe new time.

Value

A double-precision floating-point value indicating the current playback time inseconds.

If the media is not yet playing, the value ofcurrentTime indicates thetime position within the media at which playback will begin once theplay() method is called.

SettingcurrentTime to a new value seeks the media to the given time, ifthe media is available.

For media without a known duration—such as media being streamed live—it's possible thatthe browser may not be able to obtain parts of the media that have expired from themedia buffer. Also, media whose timeline doesn't begin at 0 seconds cannot be seeked toa time before its timeline's earliest time.

The length of the media in seconds can be determined using theduration property.

Examples

js
const video = document.createElement("video");console.log(video.currentTime);

Usage notes

Reduced time precision

To offer protection against timing attacks andfingerprinting, the precision ofvideo.currentTime might get rounded depending on browser settings. In Firefox, theprivacy.reduceTimerPrecision preference is enabled by default and defaults to 2ms. You can also enableprivacy.resistFingerprinting, in which case the precision will be 100ms or the value ofprivacy.resistFingerprinting.reduceTimerPrecision.microseconds, whichever is larger.

For example, with reduced time precision, the result ofvideo.currentTime will always be a multiple of 0.002, or a multiple of 0.1 (orprivacy.resistFingerprinting.reduceTimerPrecision.microseconds) withprivacy.resistFingerprinting enabled.

js
// reduced time precision (2ms) in Firefox 60video.currentTime;// Might be:// 23.404// 24.192// 25.514// …// reduced time precision with `privacy.resistFingerprinting` enabledvideo.currentTime;// Might be:// 49.8// 50.6// 51.7// …

Specifications

Specification
HTML
# dom-media-currenttime-dev

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp