Don't create a promise unless the context exists

This commit is contained in:
Richard Davey 2019-02-04 23:29:39 +00:00
parent cfe6452924
commit ba381f8e3d

View file

@ -147,14 +147,17 @@ var WebAudioSoundManager = new Class({
var unlockHandler = function unlockHandler ()
{
_this.context.resume().then(function ()
if (_this.context)
{
document.body.removeEventListener('touchstart', unlockHandler);
document.body.removeEventListener('touchend', unlockHandler);
document.body.removeEventListener('click', unlockHandler);
_this.unlocked = true;
});
_this.context.resume().then(function ()
{
document.body.removeEventListener('touchstart', unlockHandler);
document.body.removeEventListener('touchend', unlockHandler);
document.body.removeEventListener('click', unlockHandler);
_this.unlocked = true;
});
}
};
if (document.body)