When I use Player.playlistCollection.newPlaylist("name")
it creates a name.wpl file in the default playlist directory (C:\Users\username\Music\Playlists). How can I open this file when I restart the application and pass it to the Player?
I solved it by creating custom playlist files where every line is a media file url. So when the application starts, it reads the file line by line and adds it to the wmp playlist.
private WMPLib.IWMPPlaylist openPlaylist(string playlistName)
{
WMPLib.IWMPPlaylist tempPlaylist = Player.newPlaylist(playlistName, null);
using (System.IO.StreamReader sr = new System.IO.StreamReader(System.IO.Directory.GetCurrentDirectory() + "\\playlists\\" + playlistName + ".cpt"))
{
while (sr.Peek() >= 0)
{
string tempMediaUrl = sr.ReadLine();
WMPLib.IWMPMedia tempMedia = Player.newMedia(tempMediaUrl);
tempPlaylist.appendItem(tempMedia);
}
return tempPlaylist;
}
}