Hiya. I am working on a project in Unity, and I’ve gotten stuck. I want the player to be able to select an audio file from their PC and have my program add it to a playlist to be listened to. I have a functional Playlist, and I can create space for a new song and open the explorer to let the player choose a file, but I can’t get program to add the AudioClip to the playlist.
public AudioClip[] currentPlaylist;
string path;
public AudioClip newSong;
public void OpenExplorer()
{
path = EditorUtility.OpenFilePanel("Add Song", "", "mp3");
GetSong();
}
void GetSong()
{
if (path != null)
{
UpdatePlaylist();
}
}
void UpdatePlaylist()
{
WWW www = new WWW("file:///" + path);
newSong = www.GetAudioClip();
Array.Resize(ref currentPlaylist, (currentPlaylist.Length+1));
currentPlaylist[currentPlaylist.Length-1] = newSong;
}
I’m scratching my head at what isn’t working, and I’m not sure if I need to make a fix to a bug here or if I just need to use a totally new approach. Sorry if this is a really simple question.