0
votes

I am building a Music PLayer and so I have chosen to use the library of Window Media Player: Now I got stuck because I wish to show the song's name in a listBox and change songs in real time but I don't know how do that. I store songs from a Folder, so when the Music Player play the songs from the Url.

code snippet :

 private void PlaylistMidday(String folder, string extendsion)
 {
    string myPlaylist = "D:\\Music\\The_Chemical_Brothers-Do_It_Again-(US_CDM)-2007-SAW\\";
    ListView musicList = new ListView();

    WMPLib.IWMPPlaylist pl;

    WMPLib.IWMPPlaylistArray plItems;

    plItems = player1.playlistCollection.getByName(myPlaylist);

    if (plItems.count == 0)

        pl = player1.playlistCollection.newPlaylist(myPlaylist);

    else

        pl = plItems.Item(0);

    DirectoryInfo dir = new DirectoryInfo(folder);

    FileInfo[] files = dir.GetFiles(extendsion,  SearchOption.AllDirectories);

    foreach (FileInfo file in files)
    {

        string musicFile01 = file.FullName;

        string mName = file.Name;

        ListViewItem item = new ListViewItem(mName);

        musicList.Items.Add(item);

        WMPLib.IWMPMedia m1 = player1.newMedia(musicFile01);

        pl.appendItem(m1);

    }

    player1.currentPlaylist = pl;

    player1.Ctlcontrols.play();

}

On Load I decide to play the songs of "myPLaylist" so I ask you do you know some way how to show the songs of my playlist in a listbox and when I click on the selected item the song will get changed?

1

1 Answers

0
votes

you can use ((IWMPcontrols)player.ctlcontrols).setAudioLanguage

More Details