- Home /
WWW GetAudioClip not working correctly for Unity 4?
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.Contains(".mp3") || userFilePath.Contains(".Mp3") || userFilePath.Contains(".MP3"))
song.clip = www.GetAudioClip(false, true, AudioType.MPEG);
www.Dispose();
}
I have the same problem, I also tried the new AudioType.AUDIOQUEUE with no success... ps. the problem remains with the newest update : 4.1.1f4
a short bump, to focus the problem a bit. Loading the files locally, as in the example above, I cannot get a stream, loading the full file works (with a horrible full freeze on mobile devices, commented on in other threads, due to the load of such a large file), whereas loading an mp3 from a http server will work most of the time (some reported trouble here, but they seem to have gotten better with the latest update :)
great, i just submitted a similar question about WWW.GetAudioClip not working with OGG files inside Unity 4.2.2f1 (doesn't work with mp3s either)
:(
I have the same problem with Unity V4.3.0f. I'm using the code from the post http://answers.unity3d.com/questions/392257/i-cant-use-wwwgetaudioclip.html
The code works very well with regard to listing the files in the directory on my hard drive, but the files will not play. When I look in the AudioSource in the inspector during run-time the name of the clip is not shown (I assume it should be), although an un-named clip symbol is shown. I there anyone out there that can confirm whether GetAudioClip() is working at all? and if it is what specific code do I need to get it to work. Thanks in advance for your help.
Answer by Andy-Korth · Oct 15, 2014 at 08:15 PM
This issue seems fixed in Unity 4.5.4f1. I load my files with:
AudioClip clip = www.GetAudioClip(false, false, AudioType.AUDIOQUEUE);
Be mindful of the path, especially on iOS when reading off the disk. Start with "file://". Default path locations have moved around in the most recent iOS version or two.
Your answer
Follow this Question
Related Questions
Issues with WWW resource loading 1 Answer
WWW.GetAudioClip Freeze 1 Answer
How to have www streaming to work with a radio station? 1 Answer
loading/streaming audioclip using www class [android] 0 Answers
How do i stream music from a server? 0 Answers