title: c# WPF how to repeat MediaElement playback from mediaended event handler without declaring new source?
body: <p>I'm playing a video in WPF.i want it to loop so what I did is when the mediaended event fires, I play back my video. so this will get me a loop. prob is why do u I have to create new source again? why can't I just call 'play'?</p>
  
  <p>I don't want to do it in XAML as for some reason.</p>
  
  <p>have a look at my code snippet:</p>
  
  <pre><code>string startPath System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
  
  
  public Window1()
      {
          InitializeComponent();
          media.Source = new Uri(startPath + @"playlist.wpl");
          media.play();
      }
  
  private void Media_Ended(object sender, EventArgs e)
      {
          media.Source = new Uri(startPath + @"playlist.wpl"); //if i dont put this line, video wont play..seems like it cant get the source
          media.Play();
      }
  </code></pre>
  
  <p>or is there a proper way to loop NOT in XAML but in here .cs file?</p>