title: Issue with getting the duration of an audio file using the MediaPlayer class
body: <p>I'm working with some Audio files in my app (mp3, wav, ..etc)
  I was using the MediaPlayer class from the <code>System.Windows.Media</code> namespace..
  but I had some problems with computing the duration of the sound file, 
  my form is actually a small media player, it has a <code>TrackBar</code> a <code>ComboBox</code>
  and the normal <code>next</code>, <code>previous</code> and <code>play</code> buttons ..
  I used this code to get the duration of the sound file to determine the maximum value of the track bar:</p>
  
  <pre><code>private void MusicComboBox_SelectedIndexChanged(object sender, EventArgs e)
  {   
    System.Windows.Duration duration = Player.NaturalDuration;
    SeekBar.Value = 0;
    Player.Open(new Uri(soundEffectPackage.GetMusicAt(MusicComboBox.SelectedIndex)));
    if(duration.HasTimeSpan)
      SeekBar.Maximum = duration.TimeSpan.Seconds;  
  }
  </code></pre>
  
  <p>This is working fine with only some of the files, 
  while other files don't have a <code>TimeSpan</code> so the if isn't getting executed, and if i removed the if, I'll get an exception saying that I should check first to see if the <code>HasTimeSpan</code> is true, then moving on.</p>
  
  <p>How can i fix this?
  How can i get the duration of the audio file ?
  And what do they mean by a time span ?</p>
  
  <p>Any help would be appreciated, thank you :)</p>