From c734a3c3efc12b654e1239d167f51e0fcdfa8a3a Mon Sep 17 00:00:00 2001 From: artemlvov Date: Mon, 24 Dec 2018 16:30:32 +0100 Subject: [PATCH] Fix: Sounds stop playing after context is interrupted (fixes #928) --- src/howler.core.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/howler.core.js b/src/howler.core.js index 2ca3935a..c6a5de8b 100644 --- a/src/howler.core.js +++ b/src/howler.core.js @@ -463,14 +463,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;