- Home /
Audioclip from WWW.getAudioClip(...) never gets ready
My goal is to dynamically import an audio file during runtime without manually importing it from the editor. Searching around the net, I found out that the usual way of doing this is using the WWW class and calling getAudioClip(...). However, no matter what I do, the resulting AudioClip always reports false whenever I call isReadyToPlay. The audio file I'm trying to import is an .ogg file.
This is my code...
IEnumerator loadFile(string path){
print ("file://"+path);
WWW www = new WWW("file://"+path);
while (!www.isDone)
yield return 0;
AudioClip myAudioClip = www.GetAudioClip(false);
music = myAudioClip;
}
Comment
Best Answer
Answer by hotdawg · Feb 12, 2014 at 12:02 PM
Solved the problem by passing absolute URLs in WWW instead of relative URLs.