diff --git a/src/howler.core.js b/src/howler.core.js index c8c3365c..54420e38 100644 --- a/src/howler.core.js +++ b/src/howler.core.js @@ -482,14 +482,19 @@ self._suspendTimer = null; self.state = 'suspending'; - self.ctx.suspend().then(function() { + + var handleSuspension = function() { self.state = 'suspended'; if (self._resumeAfterSuspend) { delete self._resumeAfterSuspend; self._autoResume(); } - }); + }; + + // Either suspension is resolved or rejected (i.e. in case of interrupted state of audio context) + // the Howler's 'suspending' state needs to be updated. + self.ctx.suspend().then(handleSuspension, handleSuspension); }, 30000); return self; @@ -506,10 +511,10 @@ return; } - if (self.state === 'running' && self._suspendTimer) { + if (self.state === 'running' && self.ctx.state !== 'interrupted' && self._suspendTimer) { clearTimeout(self._suspendTimer); self._suspendTimer = null; - } else if (self.state === 'suspended') { + } else if (self.state === 'suspended' || self.state === 'running' && self.ctx.state === 'interrupted') { self.ctx.resume().then(function() { self.state = 'running'; @@ -868,7 +873,7 @@ } }; - if (Howler.state === 'running') { + if (Howler.state === 'running' && Howler.ctx.state !== 'interrupted') { playWebAudio(); } else { self._playLock = true;