- Home /
Load an external folder full of mp3's into array at runtime c#
I made an audio visualizer and I have an array of music that it loops through. I want the user to be able to use their own folder. I want for them to either choose a folder or a folder to be created for them to put their music into. I can't have it in the asset folder because it is compiled into a single file when built...Is this possible and how would I do it.
Answer by Bunny83 · Mar 03, 2017 at 06:44 PM
No, not out-of-the-box as Unity can't load mp3 files at runtime. Only the editor can load mp3. At runtime Unity can only load WAV, OGG and some other formats. Note that mp3 is in fact listed there, but only on mobile phones and only as streaming background music. That's because mobile phones have a hardware mpeg decoder which can decode mp3. However even on mobile phones you can't access the PCM data.
If you want to be able to load mp3 at runtime you have to use a third party library that can decode mp3. For example Mp3Sharp. Finding and loading the raw mp3 files / data you would simply use the usual file IO classes from the System.IO namespace.
Answer by mgstauff · Feb 07, 2020 at 02:49 AM
I was looking for the same thing and found AudioImporter, and free unity store asset for importing mp3 files. @hard-coded
Your answer
![](https://koobas.hobune.stream/wayback/20220612112252im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Dynamically load AudioClip during runtime 1 Answer
Audio clip compression by c# script at runtime ,Compression of audio clip by c# script at runtime 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
What is the equivalent of EditorUtility.OpenFolderPanel for runtime? 0 Answers