positionX 特性为 PannerNode interface specifies the X coordinate of the audio source's position in 3D Cartesian coordinates, corresponding to the horizontal axis (left-right).

The complete vector is defined by the position of the audio source, given as ( positionX , positionY , positionZ ), and the orientation of the audio source (that is, the direction in which it's facing), given as ( orientationX , orientationY , orientationZ ).

Depending on the directionality of the sound (as specified using the attributes coneInnerAngle , coneOuterAngle ,和 codeOuterGain ), the orientation of the sound may alter the perceived volume of the sound as it's being played. If the sound is pointing toward the listener, it will be louder than if the sound is pointed away from the listener.

AudioParam contained by this property is read only; however, you can still change the value of the parameter by assigning a new value to its AudioParam.value 特性。

句法

var positionX = PannerNode.positionX;
PannerNode.positionX.value = newPositionX;
					

AudioParam whose value is the X coordinate of the audio source's position, in 3D Cartesian coordinates. The default value is 0.

范例

The following example starts an oscillator, and pans it to the left after 1 second, to the right after 2 seconds, and back to the center after 3 seconds.

const context = new AudioContext();
const osc = new OscillatorNode(context);
const panner = new PannerNode(context);
panner.positionX.setValueAtTime(-1, context.currentTime + 1);
panner.positionX.setValueAtTime(1, context.currentTime + 2);
panner.positionX.setValueAtTime(0, context.currentTime + 3);
osc.connect(panner)
   .connect(context.destination);
osc.start(0);
					

规范

规范 状态 注释
Web 音频 API
The definition of 'positionX' 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
positionX Chrome Yes Edge ≤18 Firefox 50 IE 不支持 No Opera Yes Safari 不支持 No WebView Android Yes Chrome Android Yes Firefox Android 50 Opera Android Yes Safari iOS 不支持 No Samsung Internet Android Yes

图例

完整支持

完整支持

不支持

不支持

另请参阅

元数据

  • 最后修改: