Closed davidfrerichs closed 2 years ago
This problem is well known. Unfortunately there are anti distraction rules for each browser.
Chrome's autoplay policies are simple:
See also https://developer.chrome.com/blog/autoplay/.
Safari's and Firefox's autoplay policies are similar, but not all equal.
That means for X3D content in most browsers the user must click (by a TouchSensor) to start a sound.
this problem is not related to the autoplay policy. there seems to be a bug on Safari iOS related to either spatialization TRUE or loop TRUE or something related. Please compare the two links on Chrome MacOS then compare them on Safari iOS. They both hold back on playing audio until a touch happens but one works on both Chrome MacOS and Safari iOS and the other does not (failing audio on Safari iOS).
Potentially useful to note that neither works correctly on Safari MacOS
There is this error on Safari in the developer console:
Unhandled Promise Rejection: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.
How to Make Autoplay Work in Safari:
I recognized that the sound plays unevenly, this can be caused by the format, maybe mp3 is better. Try making an html page with audio element, to hear how it plays the sound.
By the way spatialize
is not yet implemented, although it is now possible in JavaScript, as I just figured out :).
X3D with VRML97 import - https://davidfrerichs.github.io/vrml/crutch/crutch.html
Audio behaves correctly on Chrome Version 97.0.4692.71 (Official Build) (x86_64) for MacOS
Same file on Safari for iOS 15.2.1, audio does not play at all
AudioClip plays fine on Safari for iOS 15.2.1 for clips where spatialize FALSE. For example: https://davidfrerichs.github.io/vrml/bliss_episodes/e5.html