Hey, needed a couple of days to pull everything together. Leaving out what Audio Engine does for now, I find getting WebAudio started consistently in a WebXR session is approaching impossible. Some of this is beyond direct control, but some is. I will describe both.
==============================================================================
First, there is no “operational” indicator of an intention to use audio. The little thing to click only shows up AFTER an attempt to load/play a sound. Kind of too late for the first sound. There is an boolean Engine constructor option, audioEngine
, but I could not find code that actually read it. If that switch could cause the UI to come up that would be good.
There are “tricks” that could be done like a “sacrificial sound” to prime the pump run to get the UI up, but that is best left for code that the programmer does not control.
==============================================================================
The XR part is when going from a web page with an active XR session ( & audioContext) directly to another page, which also immediately requests an XR session. There is a process browsers follow, which allow the new page to automatically start in a XR session without asking first. This is done using a term sessiongranted
. This is described in GitHub - immersive-web/navigation: Repository for the discussion and research in to navigating from page to page whilst staying in immersive mode. Feature leads: Rik Cabanier and Brandon Jones.
Having the audio engine permission also be carried over is really important. I understand the restrictions on audio for the document world. For documents, it makes sense not to allow, without permission, sound to immediately start or allow page makers to do creepy stuff, like have a “check out our blue light specials” sound when mouse tracking indicates viewer is about to leave.
XR, or full page canvas pages, are more like TV, not documents. Imagine having to hit the un-mute button every time you changed the channel on your TV. That would old really fast.
To compound the problem, the viewer would then have to leave XR to see the audio permission button, or the page would have set up to deal with it itself. Even then the user would still have to do something. I am not sure what to do about this. Any suggestions?