BaseAudioContext: currentTime プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.

currentTimeBaseAudioContext インターフェイスの読み取り専用プロパティで、再生、タイムラインの可視化などのスケジューリングで使用できる単純増加するハードウェア時間の秒数を倍精度浮動小数点型で返します。 0 から始まります。

浮動小数点数です。

js
const audioCtx = new AudioContext();
// 古い webkit/blink ブラウザーでは接頭辞が必要です

// …

console.log(audioCtx.currentTime);

時刻の精度の縮小

タイミング攻撃やフィンガープリントに対する保護を提供するために、ブラウザーの設定によっては audioCtx.currentTime の値が丸められることがあります。 Firefox では、環境設定の privacy.reduceTimerPrecision が既定で有効になっており、 Firefox 59 では 20us、60 では 2ms になっています。

js
// reduced time precision (2ms) in Firefox 60
audioCtx.currentTime;
// 23.404
// 24.192
// 25.514
// …

// reduced time precision with `privacy.resistFingerprinting` enabled
audioCtx.currentTime;
// 49.8
// 50.6
// 51.7
// …

Firefox では、 privacy.resistFingerprinting を有効にすると、精度は 100ms または privacy.resistFingerprinting.reduceTimerPrecision.microseconds の値のどちらか大きいほうになります。

仕様書

Specification
Web Audio API
# dom-baseaudiocontext-currenttime

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
currentTime

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報