coderef

AudioListener setPosition() and setOrientation()Limited availability

The setPosition() and setOrientation() methods of the AudioListener API set the virtual position and orientation of a person relative to sound sources, to spatialize audio in a Web Audio context.

Not yet supported in all major browsers — check the table and provide a fallback.

Discouraged: The setPosition() and setOrientation() methods are equivalent to using an AudioListener instances's positionX, positionY, positionZ, forwardX, forwardY, forwardZ, upX, upY, and upZ properties. Use instead: AudioListener

Browser support

DesktopChrome
1–13Not supported
14+Supportedsince Sep 16, 2011
Current: 155
Edge
12+Supportedsince Jul 29, 2015
Current: 154
Firefox
1–24Not supported
25+Supportedsince Oct 29, 2013
Current: 157
Safari
1–5.1Not supported
6+Supportedsince Jul 25, 2012
Current: 27
MobileChrome Android
18+Supportedsince Jun 27, 2012
Current: 155
Firefox Android
4–24Not supported
25+Supportedsince Oct 29, 2013
Current: 157
Safari iOS
1–5Not supported
6+Supportedsince Sep 10, 2012
Current: 27

How to use

Support is still inconsistent across browsers. Use feature detection and test carefully.

Example

Full syntax and examples are on MDN: setOrientation.

Feature detection

JS · check before using
if ("AudioListener" in globalThis && "setOrientation" in AudioListener.prototype) {
  // AudioListener.setOrientation is available
}

Sub-features

Support for each part of the feature (2). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
AudioListener.setOrientation141225618256
AudioListener.setPosition141225618256