I am trying to load a mp3 from the streamingasset folder in a unity project running under ios. in the editor everything works fine, but on the iphone the mp3 is not loading. i now about the filepath issues, but i assumed to have done everything correct. here is the code’:
string fileName = "mytestfile";
if (Application.platform == RuntimePlatform.IPhonePlayer) {
path = "file:/" + System.IO.Path.Combine (Application.streamingAssetsPath, fileName + ".mp3");
} else {
path = "file://" + Application.dataPath + "/StreamingAssets/" + fileName + ".mp3";
}
Debug.Log ("LOAD FROM STREAMING ASSET " + path);
// Start a download of the given URL
WWW request = new WWW (path);
// Wait for download to complete
yield return request;
// use request.audio
AudioClip loadedMp3 = request.GetAudioClip (false, false);
Debug.Log ("Result length " + loadedMp3.length);
And here is the output in xcode:
LOAD FROM STREAMING ASSET file://var/mobile/Applications/{appid}/appname.app/Data/Raw/mytestfile.mp3
Result length 0
Anyone any idea what i am doing wrong? as i said, in the editor everything works fine.
thank you und best regards wolfgang