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: 155Edge
12+Supportedsince Jul 29, 2015
Current: 154Firefox
1–24Not supported
25+Supportedsince Oct 29, 2013
Current: 157Safari
1–5.1Not supported
6+Supportedsince Jul 25, 2012
Current: 27MobileChrome Android
18+Supportedsince Jun 27, 2012
Current: 155Firefox Android
4–24Not supported
25+Supportedsince Oct 29, 2013
Current: 157Safari iOS
1–5Not supported
6+Supportedsince Sep 10, 2012
Current: 27How 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
}Documentation (MDN)
Specification
Sub-features
Support for each part of the feature (2). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| AudioListener.setOrientation | 14 | 12 | 25 | 6 | 18 | 25 | 6 |
| AudioListener.setPosition | 14 | 12 | 25 | 6 | 18 | 25 | 6 |