[SOLVED]Play mp3 files on android

Updated on March 8, 2017 in [A] Audio
Share on Facebook0Tweet about this on Twitter0Share on Google+0Share on Reddit0
1 on March 8, 2017

Hello guys, i’m new here, but i follow brackeys channel long time, so, near to the topic, i have a problem and as title says, i can’t play mp3 files on android from local device. I tried to use NAudio to play this and even converted mp3 to wav but with no succes, it’s just playing on Windows. I tried unity forum but seems no one is trying to help me, so i’m appealing to you guys, please, i really need this for my project. Code is:

 IEnumerator PlayThis(string url)
 {
 WWW www = new WWW(url);
 yield return www;
 AudioSource audio = GetComponent();
 audio.clip = NAudioPlayer.FromMp3Data (www.bytes);
 audio.Play();
 }
 

starting coroutine is something like this : “StartCoroutine(PlayThis(“file://”+_curMusicPaths[i]));“, and cuMusicPaths i’m getting from DirectoryInfo and it’s FullName(full link)

  • Liked by
Reply
0 on March 8, 2017

Lock this post please, i found the solution.
I’m kinda dumb, i want such a complex code, but it shows to be such easy, anyway, the code to play music on android:

 IEnumerator PlayThis(string url)
 {
         WWW www = new WWW(url);
         yield return www;
         AudioSource audio = GetComponent<AudioSource>();
         audio.clip = www.GetAudioClip(false, true);
        audio.Play();
 }

  • Liked by
Reply
Cancel