AudioContextOptions dictionary (used when instantiating an AudioContext ) may contain a property named latencyHint , which indicates the preferred maximum latency in seconds for the audio context. The value is specified either as a member of the string enum AudioContextLatencyCategory or a double-precision value.

句法

audioContextOptions.latencyHint = "interactive";
audioContextOptions.latencyHint = 0.2;
var latencyHint = audioContextOptions.latencyHint;
					

The preferred maximum latency for the AudioContext . There are two ways this value can be specified.

The best way to specify the preferred latency is to use a value form the string enum AudioContextLatencyCategory . In fact, the default value of latencyHint is "interactive" (meaning the browser should try to use the lowest possible and reliable latency it can).

The value can also be specified as a double-precision floating-point value, specifying the preferred maximum latency in seconds. This provides more precise control over the balance between audio latency and device energy usage.

To determine the actual latency of the context after creating it, check the value of the context's baseLatency 特性。

规范

规范 状态 注释
Web 音频 API
The definition of 'AudioContextOptions.latencyHint' in that specification.
工作草案 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
latencyHint Chrome 60 Edge ≤79 Firefox 61 IE No Opera ? Safari ? WebView Android 60 Chrome Android 60 Firefox Android 61 Opera Android ? Safari iOS ? Samsung Internet Android 8.0

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

另请参阅

元数据

  • 最后修改: