Better way to load local assets than WWW?

So I made this pretty cool looking visualizer that reads any music file and, well, visualizes the music. I just added in the ability to load local files from your computer/smartphone.

I am currently using the WWW class to load the music, but it seems to load 99% of the file really fast, then spend a few seconds (nearly a minute on my Android) to actually start playing the music. My code for loading the music is below:

function GetTrack (track : int) {
    www = new WWW ("file://"+ audioClips[track]);
    trackName = audioClips[track];
    
    
	if(www.isDone){
		var currClip = www.audioClip;
		var Audio = gameObject.GetComponent(AudioSource);
		Audio.clip = currClip;
		audio.Play();
   }
}

So what I’m asking is: Is there a better/faster way to load local files, or is there a way to start the music playing before the “download” finishes?

I’ve tried playing the audio when www.progress == 0.5; for example, but then no audio played. I can’t seem to figure this one out. thanks for the help!

[EDIT] These are not assets that are downloaded with the app, they are literally any *.mp3 file on your device, so i can’t load an asset bundle, for example.

(BTW, there’s a working example on my website if you want to check it out, but it only plays one track since it hasn’t been updated with the new code yet >> http://www.fpsyndicate.com/visualizer)

Thanks!

Can’t help you but i just wanted to say that your app is funny, i like it :slight_smile:

try to use a C# File Stream (from System.IO) to read the files.

Have you looked at Resources.Load?

That looks really promising, but i can’t seem to figure out how to convert the Stream into a GameObject/asset. Any hints?

I looked into this, but as far as i can tell, it will only load an asset that is within the Assets folder of your project. Is there a way to hack this to get it to read any file? I’m trying to read audio files from anywhere on a person’s computer/smartphone.