Skip to content

Commit

Permalink
Use fallback for position in Safari
Browse files Browse the repository at this point in the history
Chrome's deprecation fix isn't supported in Safari. How fun.
  • Loading branch information
goldfire committed May 9, 2018
1 parent e85f6bd commit 6985d63
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions src/plugins/howler.spatial.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,13 @@
}

if (pannerType === 'spatial') {
sound._panner.positionX.setValueAtTime(pan, Howler.ctx.currentTime);
sound._panner.positionY.setValueAtTime(0, Howler.ctx.currentTime);
sound._panner.positionZ.setValueAtTime(0, Howler.ctx.currentTime);
if (typeof sound._panner.positionX !== 'undefined') {
sound._panner.positionX.setValueAtTime(pan, Howler.ctx.currentTime);
sound._panner.positionY.setValueAtTime(0, Howler.ctx.currentTime);
sound._panner.positionZ.setValueAtTime(0, Howler.ctx.currentTime);
} else {
sound._panner.setPosition(pan, 0, 0);
}
} else {
sound._panner.pan.setValueAtTime(pan, Howler.ctx.currentTime);
}
Expand Down Expand Up @@ -304,9 +308,13 @@
setupPanner(sound, 'spatial');
}

sound._panner.positionX.setValueAtTime(x, Howler.ctx.currentTime);
sound._panner.positionY.setValueAtTime(y, Howler.ctx.currentTime);
sound._panner.positionZ.setValueAtTime(z, Howler.ctx.currentTime);
if (typeof sound._panner.positionX !== 'undefined') {
sound._panner.positionX.setValueAtTime(x, Howler.ctx.currentTime);
sound._panner.positionY.setValueAtTime(y, Howler.ctx.currentTime);
sound._panner.positionZ.setValueAtTime(z, Howler.ctx.currentTime);
} else {
sound._panner.setOrientation(x, y, z);
}
}

self._emit('pos', sound._id);
Expand Down Expand Up @@ -601,12 +609,22 @@
sound._panner.refDistance = sound._pannerAttr.refDistance;
sound._panner.rolloffFactor = sound._pannerAttr.rolloffFactor;
sound._panner.panningModel = sound._pannerAttr.panningModel;
sound._panner.positionX.setValueAtTime(sound._pos[0], Howler.ctx.currentTime);
sound._panner.positionY.setValueAtTime(sound._pos[1], Howler.ctx.currentTime);
sound._panner.positionZ.setValueAtTime(sound._pos[2], Howler.ctx.currentTime);
sound._panner.orientationX.setValueAtTime(sound._orientation[0], Howler.ctx.currentTime);
sound._panner.orientationY.setValueAtTime(sound._orientation[1], Howler.ctx.currentTime);
sound._panner.orientationZ.setValueAtTime(sound._orientation[2], Howler.ctx.currentTime);

if (typeof sound._panner.positionX !== 'undefined') {
sound._panner.positionX.setValueAtTime(sound._pos[0], Howler.ctx.currentTime);
sound._panner.positionY.setValueAtTime(sound._pos[1], Howler.ctx.currentTime);
sound._panner.positionZ.setValueAtTime(sound._pos[2], Howler.ctx.currentTime);
} else {
sound._panner.setPosition(sound._pos[0], sound._pos[1], sound._pos[2]);
}

if (typeof sound._panner.orientationX !== 'undefined') {
sound._panner.orientationX.setValueAtTime(sound._orientation[0], Howler.ctx.currentTime);
sound._panner.orientationY.setValueAtTime(sound._orientation[1], Howler.ctx.currentTime);
sound._panner.orientationZ.setValueAtTime(sound._orientation[2], Howler.ctx.currentTime);
} else {
sound._panner.setOrientation(sound._orientation[0], sound._orientation[1], sound._orientation[2]);
}
} else {
sound._panner = Howler.ctx.createStereoPanner();
sound._panner.pan.setValueAtTime(sound._stereo, Howler.ctx.currentTime);
Expand Down

0 comments on commit 6985d63

Please sign in to comment.