create3000 / x_ite

X_ITE X3D Browser, view and manipulate X3D and VRML scenes in HTML.
https://create3000.github.io/x_ite/
Other
67 stars 15 forks source link

AudioClip fails to play Safari iOS when spatialize TRUE #94

Closed davidfrerichs closed 2 years ago

davidfrerichs commented 2 years ago

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

create3000 commented 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.

davidfrerichs commented 2 years ago

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

create3000 commented 2 years ago

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:

  1. Click on Safari > Preferences on the top menu.
  2. Click on the Websites tab at the top.
  3. Click on Auto-Play in the left column.
  4. In the section to the right called Allow websites below to automatically play media. choose Allow All Auto-Play

large_ScreenShot20171103at6 59 30PM-44621

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 :).