I made an application in C# using WinForms for desktop. I added the WMP library. If I want to play a single file (video or audio) I just do reproductor.URL = filePath
and it plays automatically (being reproductor the WMP added in the form).
Now I want to play a playlist, so I did:
curPlaylist = reproductor.playlistCollection.newPlaylist("curPlaylist");
string[] filesArray = Directory.GetFiles(@"C:\playlist", "*.mp3");
foreach (string file in filesArray)
{
WMPLib.IWMPMedia media = reproductor.newMedia(file);
curPlaylist.appendItem(media);
}
reproductor.currentPlaylist = curPlaylist;
and nothing happens, it is not playing any file.
I tried reproductor.Ctlcontrols.play();
but still nothing. If I count the elements in the playlist it says 3 (there are 3 files in the playlist folder so this is correct).
I tried also to play the first element of the playlist reproductor.Ctlcontrols.playItem(reproductor.currentPlaylist.get_Item(1));
and again nothing happens.
What am I missing?
Code is right. This is the correct way to play a playlist. Why didn't work previously? May be some driver issue, may be Visual Studio, may be some application that didn't release de audio driver. I Closed VS, restarted PC, and worked perfectly.