Hello everyone.
The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
how can I play a mp3 file in unity in the uwp
I have some external mp3 files. And in unity editor I can use NAudio to change mp3 to wav, or I can use libmpg123-0 to get the byte data. But in uwp, I encountered some problems:
NAudio.dll can't compile, libmpg123-0 can't be found.
My purpose is to change a text to speech in unity, and it should work in hololens. Now I get the mp3 stream, but I can't find a way to play it.
Who can help me?
0
Best Answer
-
t_xliang ✭
OK, finally I use the "mp3sharp" to solve the problem in hololens. I delete many codes which can't use in the UWP, and modify some codes to make it adapt to my need.
1
Answers
You can play MP3 files in unity. Or why do you feel the need to convert?
https://docs.unity3d.com/Manual/AudioFiles.html
Taqtile
Unity don't support mp3 file in windows. I use WWW to get a mp3 in my Hard disk and play it, but the unity console show "not support mp3".
Maybe try ogg?
http://answers.unity3d.com/questions/406895/load-external-mp3-file-without-streaming.html
Taqtile
OK, finally I use the "mp3sharp" to solve the problem in hololens. I delete many codes which can't use in the UWP, and modify some codes to make it adapt to my need.
hi @t_xliang ,
I have a raw audio data(audio/mpeg) which is generated at runtime(i.e it's a REST API response). Do you know how can I play the audio in AudioSource. I looked up Mp3Sharp but didn't understand how to use it in my case.
I have tried various other approaches as follows:
1. Used WWW
www = new WWW("file:///" + Path.Combine(Application.persistentDataPath, filename));
yield return www;
audioSource.clip = www.GetAudioClipCompressed(false, AudioType.MPEG));
2.
Use WavUtility class which reads the bytes from Wav file and then converts to float and creates an AudioClip
WavUtility Code: https://github.com/deadlyfingers/UnityWav
https://answers.unity.com/questions/737002/wav-byte-to-audioclip.html
3.
Holo-Academy 212 doesn’t help because it just records the user’s Audio through Microphone Manager script and playbacks the audio clip.
4.
Also, tried this approach https://forum.unity.com/threads/loading-audioclip-from-a-file-not-resource-after-www-audioclip-is-gone-unity-2017.490884/
But my wav file is generated at Persistent Data Path, so tried to provide that path also, but it didn’t work out.