0

I'm developing an app in unity for android. My app uses a bunch of audio files, each audio file is about 5Mb. I uploaded them on firebase storage. For testing, I use only three audio files, when I run the app, each audio file takes almost a minute to load. Is there n efficient way of doing this faster? Any help would be much appreciated. Thanks.

This is how I load the audio clip.

IEnumerator GetAudioClip()
    {
        using (UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip("", AudioType.OGGVORBIS))
        {
            yield return www.SendWebRequest();
            if (www.isNetworkError)
            {
                Debug.Log(www.error);
            }
            else
            {
                myClip = DownloadHandlerAudioClip.GetContent(www);
            }

            Debug.Log("Audio is loaded.");
        }
    }
derHugo
  • 83,094
  • 9
  • 75
  • 115
EA1
  • 11
  • 1
  • 4
  • [This rather old post](https://stackoverflow.com/a/43678419/15204525) explains that some devices may not implement web request efficiently and one option may be to just send a C# WebRequest instead of Unity's. – DekuDesu Jun 01 '21 at 09:54
  • @DekuDesu thank you so much for your reply, I'm using a direct link of the audio file from firebase storage as a URL for playing. Do I use firebase SDK for better speed? – EA1 Jun 01 '21 at 10:15
  • Great question. I have no clue, but possibly. Try it out and post the results! Another alternative is to continuously download the files in that background while others play, minimizing the time between no music. Be sure to try other options like directly downloading bytes (although it has its downsides as well) – DekuDesu Jun 01 '21 at 11:08
  • Thanks, @DekuDesu, but my app is an audio player, so I need to load the audio files immediately, I don't know how to load audio from firebase storage using its SDK. Now I,m using a simple download URL of my audio clip uploaded on firebase. – EA1 Jun 01 '21 at 18:05
  • Please use the correct tags! Note that [`unityscript`](https://stackoverflow.com/tags/unityscript/info) is or better **was** a JavaScript flavor like custom language used in early Unity versions and is long **deprecated** by now! – derHugo Jun 14 '21 at 07:57

0 Answers0