Search Unity

Downloading audio at runtime in WebGL Cloud Build

Discussion in 'Web' started by mattbrandmm, Sep 24, 2018.

  1. mattbrandmm

    mattbrandmm

    Joined:
    Jun 5, 2018
    Posts:
    90
    I'm using this functionality:

    Code (CSharp):
    1. private IEnumerator LoadMusicClipFromWeb(string url)
    2. {
    3.     WWW www = new WWW(url);
    4.     while (www.progress < 1.0f)
    5.         yield return new WaitForSeconds(0.1f);
    6.  
    7.     if (!string.IsNullOrEmpty(www.error))
    8.     {
    9.         Debug.Log(www.error);
    10.     }
    11.     else
    12.     {
    13.         AudioClip clip = www.GetAudioClipCompressed();
    14.         webMusicClips.Add(url, clip);
    15.         PlayMusic(clip);
    16.     }
    17. }
    To play audio clips from the web. This works great in editor, and in a local WebGL build, and in a downloaded ZIP of the Cloud Build, but through the Cloud Build interface, I don't hear the music playing.

    I've tried it with MP3, OGG, and both GetAudioClip() and GetAudioClipCompressed(). The url that I am requesting the music from has CORS set up properly.

    Is it possible to do this on Cloud Build?
     
    Last edited: Sep 26, 2018
  2. mattbrandmm

    mattbrandmm

    Joined:
    Jun 5, 2018
    Posts:
    90
    Solved!

    For anyone experiencing this same issue, the audio clip must be hosted on https in order to download from Cloud Build, as Cloud Build runs on https.