-1

I'm trying to build an app where a user can play music and mix multiple audio. I not getting an idea on how to allow the user to upload his/her own music file to the audio source which is tied to a toggle button. How i have planned to make this work is: There is a grid of toggle buttons on the screen. An edit button at the bottom. when i click on edit button the camera switches to another with a replica of this current canvas, where when u click on the buttons you should be able to upload audio files from local storage on the phone.

Please guide me as to how i have to go about this.

Tejas Achar
  • 21
  • 2
  • 9
  • You haven't shown any effort. This website does not provide code. Post the relevant code and if there are any issues or errors, somebody will help you. – Abhi Apr 05 '18 at 16:25
  • I'm not looking for the actual code so i can copy paste it. I was trying to see if some one had done something similar to this. I was actually finishing up another part of the same app. – Tejas Achar Apr 06 '18 at 05:10

1 Answers1

0

Selecting an file from the filesytem can be a bit tricky within Unity, I would use a library from the asset store for that

This one is free and should work on android.

https://assetstore.unity.com/packages/tools/input-management/simple-file-browser-98451

To load the selected Audio file as an AudioClip you can use the WWW class like this:

public void StartLoadingAudio(string path) {
    StartCoroutine(LoadAudio(path));
}

IEnumerator LoadAudio(string path)
{
    WWW www = new WWW("file://" + path);
    yield return www;
    AudioClip clip = www.GetAudioClip();
    //Do something with the AudioClip
}

Call the StartLoadingAudio function with the path you got from the File Browser