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?
How can I open a playlist file using c# wmp
1.1k views Asked by botiapa At
3
There are 3 answers
0
On
Here is an Example. Here i'm getting file from "Video" Folder within the Application Folder and Creating a Playlist and Playing in loop
private void GetMediaFiles()
{
FilePath = Application.StartupPath + "\\Videos\\";
FileCount = Directory.GetFiles(FilePath).Length;
Files = Directory.GetFiles(FilePath);
playlist = axWMPlayer.playlistCollection.newPlaylist("PlaylistName");
for (int Count = 0; Count < FileCount; Count++)
{
media = axWMPlayer.newMedia(Files[Count]);
playlist.appendItem(media);
}
RunMedia();
}
private void RunMedia()
{
try
{
if (playlist.count > 0)
{
axWMPlayer.BringToFront();
axWMPlayer.currentPlaylist = playlist;
axWMPlayer.Ctlcontrols.play();
axWMPlayer.stretchToFit = true;
}
else
{
pbDefaultImage.BringToFront();
}
}
catch (Exception ex)
{
LogException(ex);
}
}
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.