I just upgraded to Unity 4 from 3.5 and ran into a problem. I was able to load mp3s from a user selected directory and play them in game, but now my code does not seem to load the audio at all. The following code is used to get the audio clip. Again, this worked fine before. Any help would be greatly appreciated!
WWW www = new WWW(@"file://" + userFilePath);
yield return www;
if (www.error == null)
{
if (userFilePath.EndsWith(".mp3") || userFilePath.EndsWith(".Mp3") || userFilePath.EndsWith(".MP3"))
song.clip = www.GetAudioClip(false, true, AudioType.MPEG);
www.Dispose();
}
Hmmm… There seems to be a general air of mystery about mp3 support. Its even hard to find ‘official’ info on the legality of mp3s with Unity on iOS devices. Probably because MP3 itself has and still is seeing its share of legal issues. MP3 - Wikipedia
The problem is, the current docs say nothing about mp3 and standalone. Leading to a few possible conclusions based on the evidence that loading user mp3s was possible in 3.5 , but is no longer working.
First, they may have previously supported this and for some reason(likely legal) now they do not.
Or IMO, The more likely scenario is that the loading of mp3s in 3.5 on standalone though the WWW class is a loophole. One that they patched without saying anything. Probably due to the legal implications of allowing devs who have licensed Unity to have their application load and decode mp3s via software with out the legal rights to do so.
I personally would LOVE some official comment from Unity on this stuff.