Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Feedback WebGL Audio: Editor vs Builds

Discussion in 'WebGL' started by skwsk8, Jan 31, 2020.

  1. skwsk8

    skwsk8

    Joined:
    Jul 6, 2014
    Posts:
    33
    [2019.2.7f2] WebGL doesn't seem to handle downloaded audio consistently between editor and builds. We are using UnityWebRequestMultimedia.GetAudioClip().
    In editor, we get the error: "Streaming of 'mp3' on this platform is not supported", but ogg plays
    In builds, we get the error: "Streaming of 'ogg' on this platform is not supported", but mp3 plays

    Could we get a way to have mp3 be an accepted audio format in WebGL for both the editor and builds?
    Mp3 seems to be the only accepted audio format for all browsers:
    https://en.wikipedia.org/wiki/HTML5_audio#Supported_audio_coding_formats

    The Unity manual says to use AAC
    https://docs.unity3d.com/Manual/webgl-audio.html
    ...but that's not an available AudioType (Note that AAC != ACC, and ACC says not supported)
    https://docs.unity3d.com/ScriptReference/AudioType.html

    Am I missing something?
     
  2. Cafn

    Cafn

    Joined:
    Jan 8, 2015
    Posts:
    19
    Also have the same questions. Implementing a webgl application and happens the same thing:

    Editor: Mp3 not supported, ogg plays
    Builds: Ogg not suported, mp3 plays.
     
  3. ewanuno

    ewanuno

    Joined:
    May 11, 2017
    Posts:
    58
    I am importing my sounds into unity as wav, and it's working fine.
    You should really use wav, unity is going to encode it anyway.
     
  4. Cafn

    Cafn

    Joined:
    Jan 8, 2015
    Posts:
    19
    In my case, the audios are stored in a Azure Storage and are streamed into the game. Storing in wav increases the space usage by almost 10 times (from 1.3MB to 11MB).

    By now, our workaround has been:
    - Set it to play on Mp3 (which will work on openGL)
    - If on unity Editor (for debug purposes), download into the Resources folder and play it.
     
  5. ewanuno

    ewanuno

    Joined:
    May 11, 2017
    Posts:
    58
    On my project, in 2030.1 it only lets me encode as aac, and it works fine, I import my files as wav.
     
  6. skwsk8

    skwsk8

    Joined:
    Jul 6, 2014
    Posts:
    33
    @Cafn thanks for the idea! We ended up writing server code to generate both a mp3/ogg and then used preprocessor directive #if UNITY_EDITOR to determine which one to download. We may switch to the resources folder if we run into mp3 vs ogg mismatches.

    @ewanuno the issue only exists with downloaded content, which is purely dynamic in our case, so unity encoding the file during build isn't possible.

    Thanks for the responses!

    Ideally, unity needs to have support added for dynamically downloaded mp3 to the editor
     
    De-Panther likes this.