Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Howler state is still 'running' while AudioContext state is 'suspended' #1355

Open
EnzoMenegaldo opened this issue Jun 5, 2020 · 1 comment · May be fixed by #1551
Open

Howler state is still 'running' while AudioContext state is 'suspended' #1355

EnzoMenegaldo opened this issue Jun 5, 2020 · 1 comment · May be fixed by #1551

Comments

@EnzoMenegaldo
Copy link

Hi there !

It seems that when you manually suspend audioContext using its native method: 'suspend()', the Howler state is still 'running'.
Thus when we try to play it again, it doesn't work.

https://jsfiddle.net/ykczmoux/15/

After a while, Howler state will be set to 'suspended'. As so, it will work again. I don't know why.

On iOs, when you unplug headphones, its policy will suspend any audioContext. But here, our Howler state will remain 'running'. Therefore, you cannot play any sound while Howler state is still running.

Regards,

@xiaobao66
Copy link

Same issue.
In the _autoResume function, AudioContext is only resumed when Howler state is 'suspended' or Howler state is 'running' and ctx.state is 'interrupted'.

} else if (self.state === 'suspended' || self.state === 'running' && self.ctx.state === 'interrupted') {

It loses the case: Howler state is 'running' and ctx.state is 'suspended'. Because when you unplug the headphones on IOS, ctx.state will change to 'suspended' not 'interrupted'.
If we add the condition: self.ctx.state === suspended to the judgement, we can play audio again after unplugging the headphones.

else if (self.state === 'suspended' || self.state === 'running' && (self.ctx.state === 'interrupted' || self.ctx.state === 'suspended'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants