Skip to content

Commit

Permalink
Fix: Sounds stop playing after context is interrupted (fixes #928)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvov committed Dec 24, 2018
1 parent 9ad4eb1 commit c734a3c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/howler.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c734a3c

Please sign in to comment.