title: How to make Trackbar works while media is playing
body: <p>I am working on a simple mediaplayer application. It works great but I want to add some extra features. I have added a trackbar control.How can i set trackbar length the same as the music's length ?
  Like if the song is halfways the trackbars halfways.This is what I have so far</p>
  
  <pre><code> string[] files, indexed_files;
     private void button3_Click(object sender, EventArgs e)
  {
      OpenFileDialog ofd = new OpenFileDialog();
      ofd.Multiselect = true;
      if (ofd.ShowDialog() == DialogResult.OK) {
  
          files = ofd.SafeFileNames;
          indexed_files = ofd.FileNames;
          for (int i = 0; i &lt; files.Length; i++)
          {
              listBox1.Items.Add(files[i]);
          }
  
      }
      button4.Enabled = true;
  }
  
  
  
  private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
  {
      axWindowsMediaPlayer1.URL = indexed_files[listBox1.SelectedIndex];
      progressBar1.Maximum =(int) axWindowsMediaPlayer1.currentMedia.duration;
      axWindowsMediaPlayer1.PlayStateChange += axWindowsMediaPlayer1_PlayStateChange;
  
  
  
  }
  
  void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
  {
      trackBar1.Value = (int)axWindowsMediaPlayer1.Ctlcontrols.currentPosition;
  
  }
  int index = 0;
  private void button4_Click(object sender, EventArgs e)
  {
      if (listBox1.Items.Count != 0) {
  
          axWindowsMediaPlayer1.URL = indexed_files[index];
          trackBar1.Maximum = (int)axWindowsMediaPlayer1.currentMedia.duration;
  
          index++;
          index = (index % listBox1.Items.Count);
  
      }
  
  }
  </code></pre>