Skip to content

Commit

Permalink
Fix auto-pause on focus (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigtimebuddy committed Aug 15, 2023
1 parent cbf55b7 commit 705408e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/webaudio/WebAudioContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ class WebAudioContext extends Filterable implements IMediaContext
/** Handle mobile WebAudio context resume */
private onFocus(): void
{
if (!this.autoPause)
{
return;
}
// Safari uses the non-standard "interrupted" state in some cases
// such as when the app loses focus because the screen is locked
// or when the user switches to another app.
Expand All @@ -139,7 +143,11 @@ class WebAudioContext extends Filterable implements IMediaContext
/** Handle mobile WebAudio context suspend */
private onBlur(): void
{
if (!this._locked && this.autoPause)
if (!this.autoPause)
{
return;
}
if (!this._locked)
{
this._pausedOnBlur = this._paused;
this.paused = true;
Expand Down

0 comments on commit 705408e

Please sign in to comment.