Skip to content

Commit 766b110

Browse files
committed
SoundManager now uses the new Touch.addTouchLockCallback methods to handle mobile device audio unlocking.
1 parent f265f98 commit 766b110

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/sound/SoundManager.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ Phaser.SoundManager.prototype = {
261261
*/
262262
setTouchLock: function () {
263263

264-
this.game.input.touch.callbackContext = this;
265-
this.game.input.touch.touchStartCallback = this.unlock;
264+
this.game.input.touch.addTouchLockCallback(this.unlock, this);
266265
this.touchLocked = true;
267266

268267
},
@@ -271,12 +270,13 @@ Phaser.SoundManager.prototype = {
271270
* Enables the audio, usually after the first touch.
272271
*
273272
* @method Phaser.SoundManager#unlock
273+
* @return {boolean} True if the callback should be removed, otherwise false.
274274
*/
275275
unlock: function () {
276276

277277
if (this.noAudio || !this.touchLocked || this._unlockSource !== null)
278278
{
279-
return;
279+
return true;
280280
}
281281

282282
// Global override (mostly for Audio Tag testing)
@@ -306,8 +306,7 @@ Phaser.SoundManager.prototype = {
306306
}
307307

308308
// We can remove the event because we've done what we needed (started the unlock sound playing)
309-
this.game.input.touch.callbackContext = null;
310-
this.game.input.touch.touchStartCallback = null;
309+
return true;
311310

312311
},
313312

0 commit comments

Comments
 (0)