Skip to content

Commit 6985d63

Browse files
committed
Use fallback for position in Safari
Chrome's deprecation fix isn't supported in Safari. How fun.
1 parent e85f6bd commit 6985d63

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed

src/plugins/howler.spatial.js

+30-12
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,13 @@
228228
}
229229

230230
if (pannerType === 'spatial') {
231-
sound._panner.positionX.setValueAtTime(pan, Howler.ctx.currentTime);
232-
sound._panner.positionY.setValueAtTime(0, Howler.ctx.currentTime);
233-
sound._panner.positionZ.setValueAtTime(0, Howler.ctx.currentTime);
231+
if (typeof sound._panner.positionX !== 'undefined') {
232+
sound._panner.positionX.setValueAtTime(pan, Howler.ctx.currentTime);
233+
sound._panner.positionY.setValueAtTime(0, Howler.ctx.currentTime);
234+
sound._panner.positionZ.setValueAtTime(0, Howler.ctx.currentTime);
235+
} else {
236+
sound._panner.setPosition(pan, 0, 0);
237+
}
234238
} else {
235239
sound._panner.pan.setValueAtTime(pan, Howler.ctx.currentTime);
236240
}
@@ -304,9 +308,13 @@
304308
setupPanner(sound, 'spatial');
305309
}
306310

307-
sound._panner.positionX.setValueAtTime(x, Howler.ctx.currentTime);
308-
sound._panner.positionY.setValueAtTime(y, Howler.ctx.currentTime);
309-
sound._panner.positionZ.setValueAtTime(z, Howler.ctx.currentTime);
311+
if (typeof sound._panner.positionX !== 'undefined') {
312+
sound._panner.positionX.setValueAtTime(x, Howler.ctx.currentTime);
313+
sound._panner.positionY.setValueAtTime(y, Howler.ctx.currentTime);
314+
sound._panner.positionZ.setValueAtTime(z, Howler.ctx.currentTime);
315+
} else {
316+
sound._panner.setOrientation(x, y, z);
317+
}
310318
}
311319

312320
self._emit('pos', sound._id);
@@ -601,12 +609,22 @@
601609
sound._panner.refDistance = sound._pannerAttr.refDistance;
602610
sound._panner.rolloffFactor = sound._pannerAttr.rolloffFactor;
603611
sound._panner.panningModel = sound._pannerAttr.panningModel;
604-
sound._panner.positionX.setValueAtTime(sound._pos[0], Howler.ctx.currentTime);
605-
sound._panner.positionY.setValueAtTime(sound._pos[1], Howler.ctx.currentTime);
606-
sound._panner.positionZ.setValueAtTime(sound._pos[2], Howler.ctx.currentTime);
607-
sound._panner.orientationX.setValueAtTime(sound._orientation[0], Howler.ctx.currentTime);
608-
sound._panner.orientationY.setValueAtTime(sound._orientation[1], Howler.ctx.currentTime);
609-
sound._panner.orientationZ.setValueAtTime(sound._orientation[2], Howler.ctx.currentTime);
612+
613+
if (typeof sound._panner.positionX !== 'undefined') {
614+
sound._panner.positionX.setValueAtTime(sound._pos[0], Howler.ctx.currentTime);
615+
sound._panner.positionY.setValueAtTime(sound._pos[1], Howler.ctx.currentTime);
616+
sound._panner.positionZ.setValueAtTime(sound._pos[2], Howler.ctx.currentTime);
617+
} else {
618+
sound._panner.setPosition(sound._pos[0], sound._pos[1], sound._pos[2]);
619+
}
620+
621+
if (typeof sound._panner.orientationX !== 'undefined') {
622+
sound._panner.orientationX.setValueAtTime(sound._orientation[0], Howler.ctx.currentTime);
623+
sound._panner.orientationY.setValueAtTime(sound._orientation[1], Howler.ctx.currentTime);
624+
sound._panner.orientationZ.setValueAtTime(sound._orientation[2], Howler.ctx.currentTime);
625+
} else {
626+
sound._panner.setOrientation(sound._orientation[0], sound._orientation[1], sound._orientation[2]);
627+
}
610628
} else {
611629
sound._panner = Howler.ctx.createStereoPanner();
612630
sound._panner.pan.setValueAtTime(sound._stereo, Howler.ctx.currentTime);

0 commit comments

Comments
 (0)