The sound example on the playground, from which the code was taken (I assume), is working on first try in most environments. On mobile there is sometimes a punishing that need to be granted before it works.
What browser are you using? Any console errors? Anything else to report?
It’s very consistent that on any desktop browser, the sound only loads the second time through.
IN ADDITION, I tried to use the same logic for my game. In all instances, JSFiddle and the live sites on desktop, the sound doesn’t play the first time…until I reach another instance to play sound, then it plays. In other words, it doesn’t play automatically (even when it’s ready).
This is expected. The first time you play the sound the browser will not let you do it. We detect it and we propose the user to click. If you want to be sure the sound is played the first time it HAS to be from a user initiated event (like a click)