Hacker News new | ask | show | jobs
by rubatuga 1833 days ago
Once you play a sound, you’re allowed to keep playing sounds I think. Just play a silent track until sound is needed
2 comments

Which, to the parent's point, makes the restriction itself pointless? It also seems like the kind of "workaround" that will one day be patched, and suddenly your app stops working.
I might have to try this again but I think I tried this at some point and I failed to get it working but it might have been making a mistake.
Some potential things to watch for:

- try not to obtain and initialize the audio context until the triggering event has occurred

- make sure the audio context + playback occurs directly as a result of the triggering event. If the event just sets some state, and then something else is periodically watching for that state to change, it may fail. A workaround here is to just mute+play some sound on that first tap, then you're good for any later Audio contexts created+initiated however you'd like.