Skip to content

Commit ba381f8

Browse files
committed
Don't create a promise unless the context exists
1 parent cfe6452 commit ba381f8

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

src/sound/webaudio/WebAudioSoundManager.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,17 @@ var WebAudioSoundManager = new Class({
147147

148148
var unlockHandler = function unlockHandler ()
149149
{
150-
_this.context.resume().then(function ()
150+
if (_this.context)
151151
{
152-
document.body.removeEventListener('touchstart', unlockHandler);
153-
document.body.removeEventListener('touchend', unlockHandler);
154-
document.body.removeEventListener('click', unlockHandler);
155-
156-
_this.unlocked = true;
157-
});
152+
_this.context.resume().then(function ()
153+
{
154+
document.body.removeEventListener('touchstart', unlockHandler);
155+
document.body.removeEventListener('touchend', unlockHandler);
156+
document.body.removeEventListener('click', unlockHandler);
157+
158+
_this.unlocked = true;
159+
});
160+
}
158161
};
159162

160163
if (document.body)

0 commit comments

Comments
 (0)