Scirra / Construct-bugs

Public bug report submissions for Construct 3 and Construct Animate. Please read the guidelines then click the 'Issues' tab to get started.
https://www.construct.net
107 stars 83 forks source link

Local webm audio files not able to play on iOS #5587

Closed arcadesindo closed 2 years ago

arcadesindo commented 2 years ago

Problem description

So I'm trying to load the audio from local files by URL, and add it into Audio Remote URL, and play them when triggered. It works well on PC browser, Android Chrome, but not for iOS. Demo Link : https://arcadesindo.com/html5/AudioTest/

Attach a .c3p

Audio Load Test.zip

Steps to reproduce

  1. Open the link on iOS browser
  2. Click on the list, choose one of them
  3. The audio should be played (you can also click on the blue objects to trigger the selected text's sound)

Observed result

No error shows, AJAX or CORS or other.

Expected result

The audio could be played on iOS too.

AshleyScirra commented 2 years ago

The provided project uses a third-party addon "Eruda Console". Please provide a minimal project file without any third-party addons as per the bug report guidelines.

arcadesindo commented 2 years ago

The provided project uses a third-party addon "Eruda Console". Please provide a minimal project file without any third-party addons as per the bug report guidelines.

Here it's Ashley, the Eruda Console from https://www.construct.net/en/make-games/addons/551/eruda-console-no-worker for making sure there's no error in console Audio Load Test.zip

AshleyScirra commented 2 years ago

Can you provide a minimal project using the fewest possible events and objects as per the bug report guidelines? There is some complex data logic in the event sheet and it makes it very difficult to rule out a mistake in your events (which is very common) and it also makes it much harder to debug.

A simple button that plays a sound from a remote URL should suffice to demonstrate the problem, if that is really what doesn't work.

Please also make sure all referenced sound files are included.

arcadesindo commented 2 years ago

Demo : https://arcadesindo.com/html5/AudioTestSimple/

AudioLoad Simple.zip

AshleyScirra commented 2 years ago

The problem is some versions of Safari don't have built-in support for decoding WebM Opus. Construct provides its own decoder, but it only exports it with your project if the project includes any WebM Opus audio files. Otherwise it assumes you don't need WebM Opus decoding and omits the decoder to keep the exported file size smaller. If you just include a small dummy WebM Opus file in the project itself, even if it is never played, then Construct will assume you want WebM Opus decoding and include the decoder on export for Safari support.

As it happens some versions of Safari do now have built-in support for WebM Opus decoding - your original demo link can play audio for me in Safari 15.4 on macOS 12. However support seems to be inconsistent, with iPadOS for example seemingly saying it doesn't support it, but some features do work if actually used. I already filed a bug report about that: https://bugs.webkit.org/show_bug.cgi?id=238546

All other browsers have built-in support for open codecs like WebM Opus - Safari is the last one without full support. We've been waiting years and years for this already, and it looks like they are inching closer with support on macOS and partial support on iOS. Hopefully soon Safari will have full support on all platforms and then codec support headaches like this will finally be behind us!

arcadesindo commented 2 years ago

If you just include a small dummy WebM Opus file in the project itself, even if it is never played, then Construct will assume you want WebM Opus decoding and include the decoder on export for Safari support.

Aha! it works now! thank you Ashley!