Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have one OpenFileDialog control that has Multiselect = true. Now I want to add each file to windows media player playlist but I have no idea how to do that and there is no good example on the internet.

if (ofdSong.ShowDialog() == DialogResult.OK)
{
    foreach (string file in ofdSong.FileNames)
    {
        //Code to add file to the playlist
    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
191 views
Welcome To Ask or Share your Answers For Others

1 Answer

With help of DJ KRAZE that gave me the example link and JayJay who wrote that example, here is the solution.

WMPLib.IWMPPlaylist playlist = wmp.playlistCollection.newPlaylist("myplaylist");
WMPLib.IWMPMedia media;
if (ofdSong.ShowDialog() == DialogResult.OK)
{
    foreach (string file in ofdSong.FileNames)
    {
        media = wmp.newMedia(file);
        playlist.appendItem(media);
    }
}
wmp.currentPlaylist = playlist;
wmp.Ctlcontrols.play();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...