locked
How to repeat forever a song in playlist C# RRS feed

  • Question

  • User1875782719 posted

    Hi guys !

    - I have a PlayList loaded into my project, and I want it to loop just one song. Everything I've Googled up so far tells me to do this:

    axWindowsMediaPlayer1.settings.setMode("loop", true);

    - However, this only seems to make the entire PlayList repeat. The behavior I want is that, if I enable "repeat" when song 5 in the PlayList is playing, then song 5 will keep automatically repeat when it finishes (instead of proceeding to song 6). 

    - I want to repeat forever a song in playlist with window media player in my project .

    Help me , Thank !

    Saturday, December 11, 2010 11:13 PM

All replies

  • User-1659704165 posted

    Hi,


    get_Item(<your song Index number>);

    http://msdn.microsoft.com/en-us/library/dd562405%28v=vs.85%29.aspx

    Whole Collection Other property

    http://msdn.microsoft.com/en-us/library/dd562388%28v=VS.85%29.aspx

    of AxWindowsMediaPlayer


    and

    http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/a53e18a6-b9b6-41d5-b6c6-d16c0d4a0a70


    Sunday, December 12, 2010 12:10 PM
  • User1875782719 posted

    - I find this code :

    axWindowsMediaPlayer1.currentMedia = axWindowsMediaPlayer1.currentPlaylist.get_Item(listBox1.SelectedIndex);


    - But it just for ListBox , not work for ListView . How I can do ??? I feel very difficult . Hellp me , Thank !

    Monday, December 13, 2010 2:31 AM
  • User-1659704165 posted



    Some Simple use List View Which has Sample How ro find index

    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listviewcommandeventargs.aspx

    http://stackoverflow.com/questions/692120/how-to-pass-in-runtime-a-index-of-row-for-listview

    Monday, December 13, 2010 2:59 AM
  • User1875782719 posted

    Can you can to fix it help me ? . I do this like , but nothing happen :


    if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsStopped) 
                  {
                      int i = ((ListViewItem)sender).Index;
                      axWindowsMediaPlayer1.currentMedia = axWindowsMediaPlayer1.currentPlaylist.get_Item(i);
                      axWindowsMediaPlayer1.Ctlcontrols.play();
                  }



    Monday, December 13, 2010 4:13 AM
  • User-1659704165 posted

    IWMPPlaylist Playlist = null;
            public void createPlayList()
            {
                  Playlist = axWindowsMediaPlayer1.newPlaylist("Mylist", "C:\\MyPlayerList");
                  foreach (ListViewItem I in listView1.Items)
                  {
                      Playlist.appendItem(axWindowsMediaPlayer1.newMedia("Your Music Directory \\" + I.Text));
                  }
                  axWindowsMediaPlayer1.currentPlaylist = Playlist;

            }


    ........Click event .......................

        private void button1_Click(object sender, EventArgs e)
            {
                axWindowsMediaPlayer1.Ctlcontrols.playItem(Playlist.get_Item(listView1.Items.IndexOf(listView1.SelectedItems[0])));
            }

    ..............Know chnage event where i will set the value which i have play.....

       private void axWindowsMediaPlayer1_CurrentItemChange(object sender, AxWMPLib._WMPOCXEvents_CurrentItemChangeEvent e)
            {
                label1.Text = axWindowsMediaPlayer1.Ctlcontrols.currentItem.name;
                for (int x = 0; x <= listView1.Items.Count - 1; x++)
                {
                    if (listView1.Items[x].ToString().Contains(axWindowsMediaPlayer1.Ctlcontrols.currentItem.name))
                    {
                        listView1.Items[x].Selected = true;
                        return;
                    }
                }

            }

    ......................change event....


    private void axWindowsMediaPlayer1_CurrentPlaylistChange(object sender, AxWMPLib._WMPOCXEvents_CurrentPlaylistChangeEvent e)
            {
                label1.Text = axWindowsMediaPlayer1.Ctlcontrols.currentItem.name;
                for (int x = 0; x <= listView1.Items.Count - 1; x++)
                {
                    if (listView1.Items[x].ToString().Contains(axWindowsMediaPlayer1.Ctlcontrols.currentItem.name))
                    {
                        listView1.Items[x].Selected = true;
                        return;
                    }
                }
            }


    I have refered

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/278631c8-a46b-465f-b2f0-39bdd5d7cec5

    the above link


    Monday, December 13, 2010 11:22 PM