Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Audio Audio is not working from a webgl application running on ios mobile browser.

Discussion in 'Audio & Video' started by unity_107801B5E237A5D0D25D, Jul 13, 2023.

  1. unity_107801B5E237A5D0D25D

    unity_107801B5E237A5D0D25D

    Joined:
    Nov 29, 2021
    Posts:
    5
    Hi,
    when a Webgl application made to run it on a ios device in chrome and in safari, the audio from the application is not getting from the device. Is there any way to get audio from the IOS device.
    The same thing is working in Android and in Laptops.
    How to get audio from a webgl application while running in a Mobile browser (in iphones)?
     
    jendrix likes this.
  2. jendrix

    jendrix

    Joined:
    Aug 25, 2014
    Posts:
    5
    I have the same problem. I think its because of something in ios17
     
  3. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    380
    That's an interesting thought! @unity_107801B5E237A5D0D25D what version of IOS and Unity are you using. Could you provide Safari logs with WebInspector?

    Also, a peculiarity of webgl build is that an interaction is needed from the use for the audio context to start. I don't see why it would work on Android but not IOS, but does anything change if you interact with buttons,triggers, etc?
     
  4. yakkalajayaram

    yakkalajayaram

    Joined:
    Nov 17, 2020
    Posts:
    4
    Last edited: Oct 31, 2023
  5. alan10801

    alan10801

    Joined:
    Sep 20, 2019
    Posts:
    4
    When I imported the MP3 into Unity, I encountered audio issues in iOS WebGL, but it worked fine on other platforms. Later, when I switched to importing WAV files, the issue was resolved. (Sorry for using a translation tool.)
     
  6. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    380
    Different device hardware or version of OS sometimes have different behaviors, it is quite hard to develop and test for all the variations. The best thing you could do is to submit a bug report using a minimal project reproducing the issue, and it is very important to add the information related to your device:

    * What is the model of the phone
    * What version of OS is it running
    * What is the version of Unity you used to build this project
     
  7. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    380
    That is very interesting... it looks like an asset importing tool bug. Does it happen with ALL mp3 files or only specific ones?

    If it happens with all the mp3 files, please submit a bug report as this is clearly an issue. If it's only on specific files, it might be worth trying to reencode them to another format, or even maybe to something-else-then-back-to-mp3, because maybe there is a minor corruption in an mpeg frame that is problematic.
     
  8. alan10801

    alan10801

    Joined:
    Sep 20, 2019
    Posts:
    4
    When importing MP3 files, we have encountered issues such as normal audio playback, no sound, or distorted audio (electronic noise) only on iOS web pages. We are transitioning from Cocos to Unity for web development, and these MP3 files do not exhibit any abnormalities when produced in Cocos. Our music partner has provided us with MP3 and WAV formats, so Unity decided to test with WAV format, and unexpectedly, it worked flawlessly.
     
  9. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    380
    Are you using the Editor on Windows, Mac or Linux?

    When you target WebGL with Unity and go to File >> Build Settings and switch to a specific platform, audio assets are all reimported to 44.1kHz MP4/AAC. Just to make it more fun, this conversion is handled by tools on the system, such as MediaFoundation, AVFoundation, FFMPEG, etc..

    It is possible that there is an issue on this conversion path and that MP3 files are not properly processed depending on your editor platform.
     
  10. alan10801

    alan10801

    Joined:
    Sep 20, 2019
    Posts:
    4
    The platform used is Windows, with Unity version 2022.3.7. The audio files are all in 48kHz format. However, when I tried the approach you mentioned, converting them to 44.1kHz using different software, they played normally.

    It's puzzling why this issue seems to be so pronounced on iOS WebGL.
     
    Last edited: Nov 2, 2023
    SeventhString likes this.
  11. tmsoagency2

    tmsoagency2

    Joined:
    Nov 8, 2023
    Posts:
    2
    The system being used is Windows, and Unity version 2022.3.7 is employed. All audio files are in 48kHz format. However, it's worth noting that when I followed your suggested approach and converted them to 44.1kHz using different software, they played without any issues.
     
    SeventhString likes this.
  12. iMagesBlues

    iMagesBlues

    Joined:
    Mar 18, 2013
    Posts:
    74
    @yakkalajayaram @SeventhString - I believe the audio-playing-in-earpiece issue occurs in iOS 17 as soon as the user accepts the camera permission popup. This is easily reproducible by creating a Webcamtexture in Unity, while playing a looping audio source.

    Thus, I don't think it is related in any way to 44.1/48kHz encoding, or is it?
     
    Last edited: Nov 28, 2023
  13. brandoncote

    brandoncote

    Joined:
    Nov 5, 2019
    Posts:
    1
    yeah i'm having the same issue with IOS 17 web gl, audio is playing through earpiece speaker and not the louder bottom speaker. Using zapwork's univeral AR
     
    emreo_ likes this.
  14. emreo_

    emreo_

    Joined:
    Jul 19, 2021
    Posts:
    1
    I am having the same issue. Using Zappar's Unity SDK.
    No problems on Android, Windows, and iPad.
    On iOS devices audio only plays through earpiece.
    I added a button and attached the audio to it for User Interaction Requirement. But it does not fix the problem.
    Any solid workarounds for this?