title: How to pause a video and play it from another position in WPF and C#
body: <p>I am trying to pause a video on a specific location in my test code, and trying to start it from a totally different position. It eventually did start from the other point but when it pauses again, it moves back to the first instance it registered. I'd like to know what am I doing wrong in this code.</p>
  
  <p>The code in CS file is</p>
  
  <pre><code>namespace timer_thread_and_gui
  {
  /// &lt;summary&gt;
  /// Interaction logic for MainWindow.xaml
  /// &lt;/summary&gt;
  public partial class MainWindow : Window
  {
          DispatcherTimer timer;
          DispatcherTimer timer1;
  
  
      public MainWindow()
      {
          InitializeComponent();
  
     }
  
      private void Window_Loaded(object sender, RoutedEventArgs e)
      {
          timer1 = new DispatcherTimer();
          timer1.Tick += new EventHandler(dispatcherTimer_Tick1);
          timer1.Interval = new TimeSpan(0, 0, 10);
  
                      timer = new DispatcherTimer();
                      timer.Tick += new EventHandler(dispatcherTimer_Tick);
                      timer.Interval = new TimeSpan(0, 0, 5);
                      video_panel.Play();
  
  
  
  
              timer1.Start();
              timer.Start();
  
  
  
  
      }
  
      private void dispatcherTimer_Tick(object sender, EventArgs e)
      {
          this.draw_an_elipse();
  
         draw_an_elipse()
      {
         ++a;
         txt.Text = a.ToString();
  
  
  
         if (a%5==0)
         {
             video_panel.Stop();
             video_panel.Position = new TimeSpan(0, 18, 30);
  
             video_panel.Play();
             timer1.Start();
         }
      }
  
     private void dispatcherTimer_Tick1(object sender, EventArgs e)
     {
  
      video_panel.Pause();
      timer1.Stop();
     }
  
  }
  </code></pre>
  
  <p>And the XAML code is</p>
  
  <pre><code>&lt;MediaElement Height="266" HorizontalAlignment="Left" Margin="12,33,0,0" Name="video_panel" 
                    VerticalAlignment="Top" Width="474" 
                    LoadedBehavior="Manual" UnloadedBehavior="Stop" 
                    Source="c:\users\ayymmoo\documents\visual studio 2010\Projects\Unfinished.avi" /&gt;
  </code></pre>