howler.js icon indicating copy to clipboard operation
howler.js copied to clipboard

Prevent cueing sounds from playing on audio unlock

Open giray123 opened this issue 5 years ago • 4 comments

When audio is not unlocked by the user (and there is no way to understand that as I understand), all the sounds that I tried to play before unlock are played upon unlock which causes a boom (a big distortion) in sound (it plays all sounds at once). Is it possible to disable this cueing mechanism? I want Howler not to cue all sounds to play after unlock.

giray123 avatar Jun 02 '20 12:06 giray123

I am facing the same issue. :(

samuelsimoes avatar May 07 '21 01:05 samuelsimoes

I even tried this:

const audio = new Howl({ src: [url] })

function play () {
  if (!Howler.ctx || Howler.ctx.state !== 'running') { return }

  audio.play()
}

to only play sounds with the context acquired, but then a lot of users started to complain that the sounds were stopping after some minutes.

samuelsimoes avatar May 07 '21 12:05 samuelsimoes

This is my current solution:

const audio = new Howl({ src: [url] })

audio.once('unlock', () => audio.stop());

kfwebdev avatar Aug 30 '21 23:08 kfwebdev

@samuelsimoes you can try turn off the autoSuspend global state

minhluuquang avatar Aug 04 '22 04:08 minhluuquang