A helper method to unlock audio on mobile devices.
Some mobile devices (like iOS) do not allow audio playback by default. Call this method in the first onTouchBegin event to unlock the website for audio playback.
stage.onTouchBegin.first.then((e) {
SoundMixer.unlockMobileAudio();
});
Source
static void unlockMobileAudio() { if (engine == SoundEngine.WebAudioApi) { try { var context = WebAudioApiMixer.audioContext; var source = context.createBufferSource(); source.buffer = context.createBuffer(1, 1, 22050); source.connectNode(context.destination); source.start(0); } catch(e) { // There is nothing we can do :( } } }