Loading OGG file, work in unity-editor, not outside


im basicly loading 10 ogg files from a certain folder. That all works fine, playing them too. But when i pulbish my build and try it from there, the songs cant load. Doesnt even give errors and it does find the songs. Im really clueless.

	string path = Application.dataPath;
	path = path.Substring(0,path.LastIndexOf("/")) + "/Music";
	allMusicClips = new ArrayList();
	DirectoryInfo info = new DirectoryInfo(path);
	fileInfo = info.GetFiles();
	for (int i=0;i<fileInfo.Length;i++)
	     WWW www = new WWW("file://"+fileInfo*.ToString());*
  •  		      StartCoroutine(FinishedLoadingSong(www));*
  •  	}*
  •  }*
  •  catch (System.Exception e)*
  •  {*
  •  	Debug.Log(e.ToString());*
  •  }*

IEnumerator FinishedLoadingSong(WWW www)

  • {*
  •  yield return www;*
  •  AudioClip temp =www.GetAudioClip(true,true);*
  •  temp.name = www.url;*
  •  allMusicClips.Add(temp);*
  •  AbleToPlayMP3 = true;*
  • }*

Edit: code format is good now, sorry about that

Since you seem to be using built in types (AudioClip), you will probably save yourself a lot of headaches if you do it “the unity way” and just put your songs in a Resource folder and use Resources.Load to load your assets.

Things will get more complicated if you need to add downloadable content/etc, but theres ways to get unity to do that for you too (AssetBundles)