I have added the playlist names from a directory in a ListBox
using LinkLabel
at run time but now I want that when I click on the LinkLabel
of that playlist, the playlist should run and play the songs.
I have no idea about how to give the path or link to the playlist in the link label and how to start playing it.
This is my code, playlistviewbar
is a ListBox
:
string[] array1 = Directory.GetFiles(@"C:\Users\LENOVO\Music\Playlists","*.wpl");
int yforlbl =5;
LinkLabel[] lblplayName = new LinkLabel[array1.Length];
for (int i = 0; i < array1.Length; i++)
{
array1[i] = Path.GetFileName(array1[i]);
lblplayName[i] = new LinkLabel();
lblplayName[i].Text = array1[i];
lblplayName[i].Location = new Point(0,yforlbl);
playlistviewbar.Controls.Add(lblplayName[i]);
yforlbl += 23;
}
ok i got it in the for loop the double click event is like this and using getbyname
mathod get the playlist and set it to current playlist
lblplayName[i].DoubleClick += (senders, es) =>
{
LinkLabel label = (LinkLabel)senders;
string PlayListFile = label.Text;
try
{
WMPLib.IWMPPlaylist list = axWindowsMediaPlayer1.playlistCollection.getByName(PlayListFile).Item(0);
axWindowsMediaPlayer1.currentPlaylist = list;
}
catch
{
//exception handling code
}
};