Created
January 20, 2018 12:46
-
-
Save pavle-goloskokovic/ceaa0945de79f3093790aec01985480f to your computer and use it in GitHub Desktop.
Now you can use this function anywhere in your code like this
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
webAudioTouchUnlock(context).then(function (unlocked) | |
{ | |
if(unlocked) | |
{ | |
// AudioContext was unlocked from an explicit user action, | |
// sound should start playing now | |
} | |
else | |
{ | |
// There was no need for unlocking, devices other than iOS | |
} | |
}, | |
function(reason) | |
{ | |
console.error(reason); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I’ve created an npm package called web-audio-touch-unlock
that exposes this method and makes it easy to use in your own projects.
Just pass your AudioContext instance to it and you’re good to go!
You can try it out yourself here.
Cheers!