frondeus / fvtt-syrin-control

Syrinscape Online Control plugin for FoundryVTT
MIT License
13 stars 4 forks source link

Consider a "Start sound" button when trying to play before interaction #76

Open LukeAbby opened 1 year ago

LukeAbby commented 1 year ago

Relevant to 0.4.0-beta5.

Modern browsers contain autoplay blocking which seems to prevent the Syrinscape module from immediately beginning to play sound on page load before interaction. In other words, a user has to click something (seems to be anything) on the page before it can play. If you play with the Syrinscape site itself, the link players use seems to recognize this and puts a clickable button to start, you'll see similar things on YouTube in that a video no longer starts playing immediately upon loading of page on such a browser.

I was personally aware of this browser pattern but I didn't tell anyone else using Foundry this, so when they loaded into the game and couldn't hear sound they were quite confused. It seems that the request to https://app.syrinscape.com/config/ is delayed until user interaction currently or something. A prominent "Start sound" button or something to indicate that Syrinscape won't be able to start before a click would be nice.

Based solely upon reading Chrome's 2019 post on autoplay it seems you can detect if it can play automatically by checking AudoContext.state and use resume after a click.

frondeus commented 1 year ago

Hmm. Good idea.

Currently SyrinControl waits for FoundryVTT audio context. And this context is created after user moves the mouse, however it is beyond my control.

Note - your players won't hear native Foundry playlist because of the same mechanism.

Now about some kind of popup that tells youto click button and play audio - maybe this is a good idea?

For sure it has to be configurable so if one player really do not care about sounds (perhaps because he finds them distracting) there should be a way to check "do not show me this popup again"

Also, perhaps you should also make an issue for the Foundry? Since that functionality should be useful also for others.

LukeAbby commented 1 year ago

I see, I've opened https://github.com/foundryvtt/foundryvtt/issues/9059 to see if they'll tackle this upstream. I would note that simply moving the mouse doesn't seem to allow playing to start in my experience, an actual click has to occur. This is on Firefox so maybe some browsers are more permissive?