leopard-js / leopard

Library for making Scratch-like projects with JavaScript.
https://leopardjs.com
MIT License
136 stars 26 forks source link

Known issue? (sound starting after green flag) #189

Open sfederici opened 4 months ago

sfederici commented 4 months ago

Is the fact that, even if the project starts immediately after translation, the sounds starts only after the green flag button has been pressed a known issue?

adroitwhiz commented 4 months ago

Yes it is, IIRC. The issue is that the Web Audio API only lets you start an AudioContext after a user interaction on the page has occurred. This is to prevent sites from auto-playing audio without any user interaction.

Does this issue only happen if starting the project immediately without any page interactions, or does it also occur after interacting with the page in some way but before the project viewer is appended to that same page? The former is unfixable due to the intentional design of the Web Audio API; the latter may be worth looking into.