Downloading Audio Durin RunTime..

Hi, I am working on a concept application right now and I need to download, store and then play, an audio file. The file is hosted on my website and I would also like to have a list, that automaticaly updates, of all the sounds on the webpage shown in unity, if that is possible…

So far, the downloading part seems to work (The progress bar created in OnGUI() fills up) But then I get an error saying:

Streaming of 'mp3' on this platform is not supported
UnityEngine.WWW:get_audioClip()
$:MoveNext() (at Assets/Code/Download_test.js:65)

I don’t really know why it’s bugging, or even if the code actually ‘works’ but Windows just doesn’t like importing sound… Anyway, here is my code:

var url : String = "http://www.mysite.com/resources/test%20sound.mp3"; 

var size : Vector2 = new Vector2(60,20);
var pos : Vector2 = new Vector2(20,40);

var progressBarEmpty : Texture2D;
var progressBarFull : Texture2D;

var barDisplay : float = 0;
var downloaded = false;

var style : GUISkin;
var ac : AudioClip;

function OnGUI()
{
	GUI.skin = style;
	
    GUI.BeginGroup (new Rect (pos.x, pos.y, size.x, size.y));
    
       GUI.Box (Rect (0,0, size.x, size.y),"");

       GUI.BeginGroup (new Rect (0, 0, size.x * barDisplay, size.y));
       
           if(GUI.Button (Rect (0,0, size.x, size.y),progressBarFull))
           {
            	if(downloaded)
            	{
            		print("Playing");
            	}
           }
           
       GUI.EndGroup ();

    GUI.EndGroup ();
    
    if(GUI.Button(Rect(Screen.width / 2 - 75, -5, 150, 50), "Download track"))
    {
    	Download();
    }
} 

function Download()
{
	downloaded = false;
	print("Downloading..");
	var download : WWW = new WWW(url);
	
	if(download.error != null)
	{
		print("Error in downloading " + download.error);
		downladed = false;
		return;
	}
	else
	{
		while(!download.isDone)
		{
			barDisplay = download.progress;
			yield;
		}
		
		yield download;
		
		ac = download.audioClip;
		downloaded = true;
				
		if(barDisplay <= 1)
		{
			barDisplay = 1;
		}
	}
	
	print("Downloaded");
	
}

Many thanks TG106

I think it means you can not stream mp3 files.
I would try to convert your file to ogg file type and then retry.
ogg is what unity uses eventually for webplayer and standalone versions.
If you are using phones (IPhone, android…) you can use MP3.