I am using the WWW class to load audio-clips at runtime as selected by the user. However, I am currently facing two issues. I am posting a code example here to explain.
IEnumerator LoadSong(string trackpath)
{
WWW checker = new WWW("file://"+trackpath);
yield return checker;
audClip = checker.GetAudioClip(true,true);
}
This NEVER works. More specifically the line yield return checker;
doesn’t. I have to replace that with while(!checker.isDone);
to forcibly wait till the clip is loaded. What am I doing wrong here?
Secondly, some songs will never load too. After extensive testing I found out that almost 5 out of 200 songs don’t load. Also even if the audio isn’t loaded audClip
doesn’t return a NULL value which suggests that something is being loaded, however
Debug.Log("No of Samples : "+audClip.samples);
Debug.Log ("Frequency : " + audClip.frequency);
Debug.Log("No of channels : "+audClip.channels);
Debug.Log("No of length : "+audClip.length);
all four values return 0. I believe this problem is related to yield not working properly.
Any help here would be much appreciated.