Load an audio file with WWW is shorter than the original

Hi,

I’m having an issue with WWW class when I want to load an audio file (mp3 file) from a local folder.
When I reproduce the file It is shorter than the original. It stops before.

If I drag the mp3 file into unity and I play the audio clip It has the right duration.

It looks like WWW class cut off the audio file.

That happened to you?
I hope I am clear.

Thanks in advance

I could fixed.

My mistake was, i think, use this AudioClip clip = www.GetAudioClip(); instead of AudioClip clip = www.GetAudioClipCompressed();

Try using the UnityWebRequest class. It’s basically a rewritten version of the WWW class, and its audio support is much better.

If that has the same issue, make sure you double check that the audio file got copied correctly to that local folder, and/or see if you can reproduce the issue with other audio files. If it’s just that one, try re-encoding it with slightly different settings.

I was going to suggest this but went to the documentation and couldn’t find anything that explicitly stated that UnityWebRequest worked with local file systems.

I’ve been using UWR to load local MP3’s in my own project, it works. Naturally you need to use the file:// protocol.

1 Like