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!
