title: Play & Pause Video from form control winform
body: <p>I want to make a form control which be able to start, pause, stop, close quiz presentation (count down time will run when start is pressed). The problem is in some presentations, there is available video (each slide can only contain a maximum of 1 video, and not every slide contains it).</p>
  
  <p>These are some code snippets I used for add video in <code>createPresentation</code> method:</p>
  
  <pre><code>PowerPoint.Slides oSlides = null;
  PowerPoint.Slide oSlide = null;
  int ctrSoal = 0;
  foreach (CQuestion myQuestion in Global.questions)
  {
      ctrSoal++;
      oSlides = oPre.Slides;
      oSlide = oSlides.Add(ctrSoal,   PowerPoint.PpSlideLayout.ppLayoutTextAndTwoObjects);
  
      oShape2 = oSlide.Shapes[4];
      oSlide.Shapes.AddMediaObject(System.IO.Path.Combine(Global.myVideoLocation, myQuestion.video), oShape2.Left, oShape2.Top, oShape2.Width, oShape2.Height);
  </code></pre>
  
  <p>So far I already tried some solutions from this <a href="https://stackoverflow.com/questions/4428900/autoplaying-a-movie-in-a-powerpoint-presentation-with-c-sharp">link</a></p>
  
  <pre><code>private void startToolStripMenuItem_Click(object sender, EventArgs e)
  {
      PowerPoint.Slides oSlides = null;
      PowerPoint.Slide oSlide = null;
      int ctrSoal = 0;
      foreach (CQuestion myQuestion in Global.questions)
      {
          ctrSoal++;
          oSlides = oPre.Slides;
          oSlide = oSlides.Add(ctrSoal, PowerPoint.PpSlideLayout.ppLayoutTextAndTwoObjects);
          var playVideo = oSlide.TimeLine.MainSequence.FindFirstAnimationFor(oSlide);
      }
  
      questionIndex = oPre.SlideShowWindow.View.Slide.SlideIndex - 1;
      questionId = myQuiz.questions[questionIndex].id;
      if (labelTimer.Text != "Paused")
      {
          duration = 0;
          duration += myQuiz.questions[questionIndex].durationMinute * 60;
          duration += myQuiz.questions[questionIndex].durationSecond;
          labelKeypadID.Text = "";
          for (int i = 0; i &lt; jumlahJawaban; i++)
          {
              arrChart[i] = 0;
          }
      }
  }
  </code></pre>
  
  <p>But it's giving me an error as a result:</p>
  
  <blockquote>
    <p>invalid arguments cannot convert from
    Microsoft.Office.Interop.PowerPoint.Slide to
    Microsoft.Office.Interop.PowerPoint.Shape</p>
  </blockquote>
  
  <p>The goal I want to achieve is a form control that can play video when user presses the start button (count down running) not auto-playing when the slideshow is run.</p>
  
  <hr>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I tried this one.  The program can running without error but the video is still not playing.</p>
  
  <pre><code>PowerPoint.Shapes objShapes = null;
  objShapes = oPre.Slides[1].Shapes;
  foreach (Microsoft.Office.Interop.PowerPoint.Shape s in objShapes)
  {
      if (s.Name.Contains(".wmv"))
      {
          s.AnimationSettings.PlaySettings.PlayOnEntry = Office.MsoTriState.msoTrue;
      }
  }
  </code></pre>
  
  <hr>
  
  <p><strong>UPDATE</strong> @jonPall</p>
  
  <p>I tried this one:</p>
  
  <pre><code>PowerPoint.Slide oSlide = null;
  PowerPoint.Shape objShape = null;
  PowerPoint.Slides oSlides = null;
  PowerPoint.Shapes objShapes = null;
  
  int ctrSoal = 1;
  oSlides = oPre.Slides;
  oSlide = oSlides.Add(ctrSoal, PowerPoint.PpSlideLayout.ppLayoutTextAndTwoObjects);
  objShapes = oPre.Slides[1].Shapes;
  
  var playVideo = oSlide.TimeLine.MainSequence.FindFirstAnimationFor(objShape);
  playVideo.Timing.TriggerType = PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious;
  </code></pre>
  
  <p>My program can run without error, but when I press start (to play video &amp; run countdown timer) it's give error</p>
  
  <blockquote>
    <p>Sequence (unknown member) : Illegal value. Object does not exist.</p>
  </blockquote>
  
  <hr>
  
  <p><strong>UPDATE</strong> @Andy</p>
  
  <pre><code>PowerPoint.Slide oSlide = null;
  PowerPoint.Slides oSlides = null;
  PowerPoint.Shapes objShapes = null;
  
  int ctrSoal = 1;
  oSlides = oPre.Slides;
  oSlide = oSlides.Add(ctrSoal, PowerPoint.PpSlideLayout.ppLayoutTextAndTwoObjects);
  
  int indexSlide = oPre.SlideShowWindow.View.Slide.SlideIndex;
  objShapes = oPre.Slides[indexSlide].Shapes;
  
  foreach (Microsoft.Office.Interop.PowerPoint.Shape objShape in objShapes) {
      string extension = Path.GetExtension(objShape.Name);
      if (extension == ".wmv") {
           //MessageBox.Show("Video Available");
           var playVideo = oSlide.TimeLine.MainSequence.FindFirstAnimationFor(objShape);
           playVideo.Timing.TriggerType = PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious;
      }
  }
  </code></pre>
  
  <p>with above script i can detect if in active slide contain video or not<br>
  but ~var~ playVideo still null in slide contain video<br>
  where i'm missing?</p>