Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Where i wrong???

Where i wrong???

Scheduled Pinned Locked Moved C#
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    VisualLive
    wrote on last edited by
    #1

    Hi i'm getting exhausted about a simple feature but sincerely i don't know how work out that :( I have this code to use Window Media Player :

    public partial class Form1 : Form
    {

        TextBox textbox;
        public Form1()
        {
            InitializeComponent();
            listBox1.SelectedIndexChanged += listBox1\_SelectedIndexChanged;
            textbox = new TextBox { Dock = DockStyle.Top };
            listBox1.SelectionMode = SelectionMode.MultiExtended;
        }
    
        private void Form1\_Load(object sender, EventArgs e)
        {
          List<string> prova =  GetListOfFiles(@"D:\\\\Torrent\\\\Depeche Mode - Sounds Of The Universe (2009)\\\\");
      
            listBox1.DataSource = prova;
            listBox1.DisplayMember = "prova";
            player1.settings.setMode("Shuffle", true);
            player1.Ctlcontrols.play();
    
        }
    
        private List<string> GetListOfFiles(string Folder)
        {
            DirectoryInfo dir = new DirectoryInfo(Folder);
            FileInfo\[\] files = dir.GetFiles("\*.mp3", SearchOption.AllDirectories);
            List<string> str = new List<string>();
            foreach (FileInfo file in files)
            {
                str.Add(file.FullName);
    
            }
            return str;
        }
           
         private void listBox1\_SelectedIndexChanged(object sender, EventArgs e)
        {
            Text = Convert.ToString(listBox1.SelectedItem);
            player1.URL = Convert.ToString(listBox1.SelectedItem);
        }
    
        private void textBox1\_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Return)
            {
                string searchFor = textBox1.Text;
                List<string> strings = (List<string>)listBox1.DataSource;
                if (multi.Checked)
                {
                    for (int i = 0; i < strings.Count; i++)
                    {
                        listBox1.SetSelected(i, strings\[i\].Contains(searchFor));
                    }
                }
                else
                {
                    listBox1.ClearSelected();
                    listBox1.SelectedIndex = strings.FindIndex(
                        s => s.Contains(searchFor));
                }
            }
        }
    
      
    }
    

    With this code i can search songs and show in a ListBox the list downloaded in a folder but my purpose is when Window Music Playe

    Y 1 Reply Last reply
    0
    • V VisualLive

      Hi i'm getting exhausted about a simple feature but sincerely i don't know how work out that :( I have this code to use Window Media Player :

      public partial class Form1 : Form
      {

          TextBox textbox;
          public Form1()
          {
              InitializeComponent();
              listBox1.SelectedIndexChanged += listBox1\_SelectedIndexChanged;
              textbox = new TextBox { Dock = DockStyle.Top };
              listBox1.SelectionMode = SelectionMode.MultiExtended;
          }
      
          private void Form1\_Load(object sender, EventArgs e)
          {
            List<string> prova =  GetListOfFiles(@"D:\\\\Torrent\\\\Depeche Mode - Sounds Of The Universe (2009)\\\\");
        
              listBox1.DataSource = prova;
              listBox1.DisplayMember = "prova";
              player1.settings.setMode("Shuffle", true);
              player1.Ctlcontrols.play();
      
          }
      
          private List<string> GetListOfFiles(string Folder)
          {
              DirectoryInfo dir = new DirectoryInfo(Folder);
              FileInfo\[\] files = dir.GetFiles("\*.mp3", SearchOption.AllDirectories);
              List<string> str = new List<string>();
              foreach (FileInfo file in files)
              {
                  str.Add(file.FullName);
      
              }
              return str;
          }
             
           private void listBox1\_SelectedIndexChanged(object sender, EventArgs e)
          {
              Text = Convert.ToString(listBox1.SelectedItem);
              player1.URL = Convert.ToString(listBox1.SelectedItem);
          }
      
          private void textBox1\_KeyDown(object sender, KeyEventArgs e)
          {
              if (e.KeyCode == Keys.Return)
              {
                  string searchFor = textBox1.Text;
                  List<string> strings = (List<string>)listBox1.DataSource;
                  if (multi.Checked)
                  {
                      for (int i = 0; i < strings.Count; i++)
                      {
                          listBox1.SetSelected(i, strings\[i\].Contains(searchFor));
                      }
                  }
                  else
                  {
                      listBox1.ClearSelected();
                      listBox1.SelectedIndex = strings.FindIndex(
                          s => s.Contains(searchFor));
                  }
              }
          }
      
        
      }
      

      With this code i can search songs and show in a ListBox the list downloaded in a folder but my purpose is when Window Music Playe

      Y Offline
      Y Offline
      Yusuf
      wrote on last edited by
      #2

      ascotravel wrote:

      when Window Music Player change song automatically the ListBoxItem will change marker and show the current song instead

      How do you know WMP changed song? If you can answer than question, then the rest is easy.

      Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]

      V 1 Reply Last reply
      0
      • Y Yusuf

        ascotravel wrote:

        when Window Music Player change song automatically the ListBoxItem will change marker and show the current song instead

        How do you know WMP changed song? If you can answer than question, then the rest is easy.

        Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]

        V Offline
        V Offline
        VisualLive
        wrote on last edited by
        #3

        Hi Yusuf, thanks to reply , sorry my english is poor i embedded Window Media PLayer in my form1

        Yusuf.A wrote:

        ascotravel wrote: when Window Music Player change song automatically the ListBoxItem will change marker and show the current song instead How do you know WMP changed song? If you can answer than question, then the rest is easy.

        that's mean i give to WMP a folder to play song so i wish set my listBox like the listBox in Windows Media Player's playlist & Winamp's playlist where there is a listbox that show the list of songs loaded and change in the next_song at the end of the current_song so the listBox with show the new song and so on....in my case when i click in the listBox to select a song it is right but when the song finish the WMP get in status stopped. Is it impossible satisfy my purpose?There is a way for work out my request? Thanks for your support. Nice Regard :)

        modified on Tuesday, March 31, 2009 1:53 PM

        Y 1 Reply Last reply
        0
        • V VisualLive

          Hi Yusuf, thanks to reply , sorry my english is poor i embedded Window Media PLayer in my form1

          Yusuf.A wrote:

          ascotravel wrote: when Window Music Player change song automatically the ListBoxItem will change marker and show the current song instead How do you know WMP changed song? If you can answer than question, then the rest is easy.

          that's mean i give to WMP a folder to play song so i wish set my listBox like the listBox in Windows Media Player's playlist & Winamp's playlist where there is a listbox that show the list of songs loaded and change in the next_song at the end of the current_song so the listBox with show the new song and so on....in my case when i click in the listBox to select a song it is right but when the song finish the WMP get in status stopped. Is it impossible satisfy my purpose?There is a way for work out my request? Thanks for your support. Nice Regard :)

          modified on Tuesday, March 31, 2009 1:53 PM

          Y Offline
          Y Offline
          Yusuf
          wrote on last edited by
          #4

          So you have embedded WMP in your form. OK. You can pass list of files to play to WMP. Is there any event you can subscribe to or any other mechanism WMP can notify you it is done playing a song? Or Is it a way to know it has started playing a new song? That is what you need to look at. I don't know the answer I am just giving you a hint as to what to look for. I could be 100 miles off the mark.

          Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]

          V 1 Reply Last reply
          0
          • Y Yusuf

            So you have embedded WMP in your form. OK. You can pass list of files to play to WMP. Is there any event you can subscribe to or any other mechanism WMP can notify you it is done playing a song? Or Is it a way to know it has started playing a new song? That is what you need to look at. I don't know the answer I am just giving you a hint as to what to look for. I could be 100 miles off the mark.

            Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]

            V Offline
            V Offline
            VisualLive
            wrote on last edited by
            #5

            HI Yusuf, i set the WMP to play songs in Random"Shuffle" way when it is playing a song it shows the name,album,etc,etc, of the current song so when its change song (stored from my folder directory) automatically change also the info about the new song the trouble is if i click on the ListBox to change song WMP follow my event but when finish to play that song WMP pass in status "Stopped" if i don't touch nothing WMP will play without interruption ,so i need to set WMP to don't pass never in status"Stopped" because the request of my client is that WMP will play for 4 hour continue without interruption and else ... My trouble is if i use the textbox "search" to search a song and play it or i click on the song's list in the ListBox to change song after this action WMP will pass in status "stopped" :( . However thanks for your support i will continue to research the best way to work out this trouble. Nice regards

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups