I'm trying to make a C# music player and to do so, I'm using the WMP object found in win forms, I got it to load files from an specific folder on the press of a button, however, I want it to load every media file (FLAC, mp3, wav...) in an specific folder and its sub folders.
by now the code I have to load files is as follows.
string[] path, files; //Global Variables to get the path and the file name
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
//This function displays the files in the path and helps selecting an index
axWindowsMediaPlayer1.URL = path[listBox1.SelectedIndex];
axWindowsMediaPlayer1.uiMode = "None";
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Multiselect = true;
if(ofd.ShowDialog() == DialogResult.OK)
{
//Function that loads the files into the list.
files = ofd.SafeFileNames;
path = ofd.FileNames;
for (int i = 0; i < files.Length; i++)
{
listBox1.Items.Add(files[i]);
}
}
}