Search Unity

Audio Loading Audio at Runtime

Discussion in 'Audio & Video' started by Rex44, Apr 5, 2020.

  1. Rex44

    Rex44

    Joined:
    Dec 1, 2014
    Posts:
    8
    Hello, I am trying to load audio at runtime on android with WWW but the audio loads with only 0 seconds in the clip and I do not understand how to fix this. This works on PC.

    Code (CSharp):
    1. private IEnumerator LoadAudioFileWWW()
    2.     {
    3.         string FilepathFinal = GetFilePath(filename);
    4.         using (WWW www = new WWW(FilepathFinal))
    5.         {
    6.             yield return www;
    7.             AudioClip clip = www.GetAudioClip();
    8.             clip.name = filename;
    9.             audioClip = clip;
    10.  
    11.         }
    12.     }
    Here is the code for loading the audio.