Skip to content

Commit f64fc42

Browse files
committed
The SoundManager now detects if the browser is running under iOS9 and uses a touchend callback to unlock the audio subsystem. Previous versions of iOS (and Android) still use touchstart. This fixes Apple's screw-up with regard to changing the way Web Audio should be triggered in Mobile Safari. Thanks Apple (thanks @MyCatCarlos for the heads-up phaserjs#2095)
1 parent d16de32 commit f64fc42

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ If you are an exceptional JavaScript developer and would like to join the Phaser
267267
* You can now load single layer Pyxel Edit TileMaps as an atlas (thanks @joshpmcghee #2050)
268268
* Canvas.getSmoothingPrefix will return the vendor prefixed smoothing enabled value from the context if set, otherwise null.
269269
* The Random Number Generator can now get and set its state via rnd.state. This allows you to do things like saving the state of the generator to a string that can be part of a save-game file and load it back in again (thanks @luckylooke #2056 #1900)
270+
* Device.iOSVersion now contains the major version number of iOS.
270271

271272
### Updates
272273

@@ -285,6 +286,8 @@ If you are an exceptional JavaScript developer and would like to join the Phaser
285286
* Added Node.js v4 stable to Travis config (thanks @phillipalexander #2070)
286287
* Optimised Canvas.getSmoothingEnabled, Canvas.setSmoothingEnabled and Canvas.setImageRenderingCrisp.
287288
* The Physics Editor Exporter (found in the resources folder of the repo) has had an option to prefix shape names and optimize JSON output added to it (thanks @Garbanas #2093)
289+
* Touch.addTouchLockCallback has a new argument `onEnd` which allows the callback to fire either on a touchstart or a touchend event.
290+
* The SoundManager now detects if the browser is running under iOS9 and uses a touchend callback to unlock the audio subsystem. Previous versions of iOS (and Android) still use touchstart. This fixes Apple's screw-up with regard to changing the way Web Audio should be triggered in Mobile Safari. Thanks Apple (thanks @MyCatCarlos for the heads-up #2095)
288291

289292
### Bug Fixes
290293

src/sound/SoundManager.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,15 @@ Phaser.SoundManager.prototype = {
265265
*/
266266
setTouchLock: function () {
267267

268-
this.game.input.touch.addTouchLockCallback(this.unlock, this);
268+
if (this.game.device.iOSVersion > 8)
269+
{
270+
this.game.input.touch.addTouchLockCallback(this.unlock, this, true);
271+
}
272+
else
273+
{
274+
this.game.input.touch.addTouchLockCallback(this.unlock, this);
275+
}
276+
269277
this.touchLocked = true;
270278

271279
},

0 commit comments

Comments
 (0)