title: Windows Phone 8 audioplayer Exception
body: <p>I got Exception of <code>System.Windows.Markup.XamlParseException</code> occurred in System.Windows.ni.dll,
  <code>System.ArgumentException</code> occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary</p>
  
  <p>my <code>MainPage.xaml</code>:</p>
  
  <pre><code>&lt;Slider Name="timelineSlider" Margin="0,185,0,376" ValueChanged="SeekToMediaPosition"/&gt;
  &lt;TextBlock Height="51" HorizontalAlignment="Left" Margin="27,334,0,0" x:Name="TitleTextBlock" Text="Title:" VerticalAlignment="Top" FontSize="28" Foreground="{StaticResource PhoneAccentBrush}" Width="400" /&gt;
  
  &lt;TextBlock Height="39" HorizontalAlignment="Left" Margin="27,383,0,0" x:Name="ArtistTextBlock" Text="Artist:" VerticalAlignment="Top" FontSize="24" FontStyle="Italic" Foreground="White" Width="400" /&gt;
  
  &lt;TextBlock Height="30" HorizontalAlignment="Left" Margin="37,559,0,0" x:Name="StartTextBlock" Text="00:00:00" VerticalAlignment="Top" Width="100" /&gt;
  &lt;TextBlock Height="30" HorizontalAlignment="Left" TextAlignment="Right" Margin="327,559,0,0" x:Name="EndTextBlock" Text="00:00:00" VerticalAlignment="Top" Width="88" /&gt;
  
  &lt;Slider HorizontalAlignment="Left" Margin="43,200,0,0" VerticalAlignment="Top" Width="395" Name="SongSlider" ManipulationCompleted="SoundSlider_ManipulationCompleted"/&gt;
  </code></pre>
  
  <p>My <code>MainPage.xaml.cs</code> file is:</p>
  
  <pre><code>private void NotProvided()
  {
      if (BackgroundAudioPlayer.Instance.Track != null)
      {
          // show soung info
          TitleTextBlock.Text = BackgroundAudioPlayer.Instance.Track.Title
          ArtistTextBlock.Text = BackgroundAudioPlayer.Instance.Track.Artist;
          // handle slider and texts
          SongSlider.Minimum = 0;
          SongSlider.Maximum = BackgroundAudioPlayer.Instance.Track.Duration.TotalMilliseconds;
          string text = BackgroundAudioPlayer.Instance.Track.Duration.ToString();
          EndTextBlock.Text = text.Substring(0, 8);
  
      }
  
      if (null != BackgroundAudioPlayer.Instance.Track)
      {
          txtCurrentTrack.Text = BackgroundAudioPlayer.Instance.Track.Title +
                                  " by " +
                                  BackgroundAudioPlayer.Instance.Track.Artist;
  
      }
  }
  
  protected override void OnNavigatedTo(NavigationEventArgs e)
  {
      if (PlayState.Playing == BackgroundAudioPlayer.Instance.PlayerState)
      {
          playButton.Content = "pause";
          txtCurrentTrack.Text = BackgroundAudioPlayer.Instance.Track.Title +
          " by " +
          BackgroundAudioPlayer.Instance.Track.Artist;
  
      }
      else
      {
          playButton.Content = "play";
          txtCurrentTrack.Text = "";
      }
  }
  
  private DispatcherTimer dispatcherTimer = new DispatcherTimer();
  
  private void startTimer()
  {
      // start timer to check position of the song
      dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 500);
      dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
      dispatcherTimer.Start();
  }
  
  private void dispatcherTimer_Tick(object sender, EventArgs e)
  {
      // song is playing
      if (PlayState.Playing == BackgroundAudioPlayer.Instance.PlayerState)
      {
          // handle slider
          SongSlider.Minimum = 0;
          SongSlider.Value = BackgroundAudioPlayer.Instance.Position.TotalMilliseconds;
          SongSlider.Maximum = BackgroundAudioPlayer.Instance.Track.Duration.TotalMilliseconds;
          // display text
          string text = BackgroundAudioPlayer.Instance.Position.ToString();
          StartTextBlock.Text = text.Substring(0, 8);
          text = BackgroundAudioPlayer.Instance.Track.Duration.ToString();
          EndTextBlock.Text = text.Substring(0, 8);
      }
  }
  
  private void SoundSlider_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
  {
      // get slider value
      int sliderValue = (int)SongSlider.Value;
      // create timespan object with milliseconds (from slider value)
      TimeSpan timeSpan = new TimeSpan(0, 0, 0, 0, sliderValue);
      // set a new position of the song
      BackgroundAudioPlayer.Instance.Position = timeSpan;
  }
  
  private void PrevButton_Click(object sender, RoutedEventArgs e)
  {
      // skip to previous song
      BackgroundAudioPlayer.Instance.SkipPrevious();
      // handle text and slider
      playButton.Content = "Pause";
      SongSlider.Value = 0;
  }
  
  private void NextButton_Click(object sender, RoutedEventArgs e)
  {
      // skip to next song
      BackgroundAudioPlayer.Instance.SkipNext();
      // handle text and slider
      playButton.Content = "Pause";
      SongSlider.Value = 0;
  }
  </code></pre>