Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions src/sound/webaudio/WebAudioSoundManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ var WebAudioSoundManager = new Class({
var context = this.context;

// setTimeout to avoid weird audio artifacts (thanks Apple)
window.setTimeout(function () {
window.setTimeout(function ()
{

if (context)
{
Expand Down Expand Up @@ -429,11 +430,12 @@ var WebAudioSoundManager = new Class({
{
var listener = this.context.listener;

var x = GetFastValue(this.listenerPosition, 'x', null);
var y = GetFastValue(this.listenerPosition, 'y', null);


if (listener && listener.positionX !== undefined)
{
var x = GetFastValue(this.listenerPosition, 'x', null);
var y = GetFastValue(this.listenerPosition, 'y', null);

if (x && x !== this._spatialx)
{
this._spatialx = listener.positionX.value = x;
Expand All @@ -444,6 +446,24 @@ var WebAudioSoundManager = new Class({
}
}

// Firefox doesn't currently implement positionX, positionY and positionZ properties on AudioListener,
// falling back on AudioListener.prototype.setPosition() method. @see https://developer.mozilla.org/en-US/docs/Web/API/AudioListener/setPosition
else if (listener)
{
if (x && x !== this._spatialx)
{
this._spatialx = x;
}
if (y && y !== this._spatialy)
{
this._spatialy = y;
}

var z = GetFastValue(listener, 'z', 0);

listener.setPosition(this._spatialx || 0, this._spatialy || 0, z);
}

BaseSoundManager.prototype.update.call(this, time, delta);

// Resume interrupted audio on iOS only if the game has focus
Expand Down