Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play & Pause Video from form control winform

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).

These are some code snippets I used for add video in createPresentation method:

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);

So far I already tried some solutions from this link

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 < jumlahJawaban; i++)
        {
            arrChart[i] = 0;
        }
    }
}

But it's giving me an error as a result:

invalid arguments cannot convert from Microsoft.Office.Interop.PowerPoint.Slide to Microsoft.Office.Interop.PowerPoint.Shape

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.


UPDATE

I tried this one. The program can running without error but the video is still not playing.

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;
    }
}

UPDATE @jonPall

I tried this one:

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;

My program can run without error, but when I press start (to play video & run countdown timer) it's give error

Sequence (unknown member) : Illegal value. Object does not exist.


UPDATE @Andy

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;
    }
}

with above script i can detect if in active slide contain video or not
but ~var~ playVideo still null in slide contain video
where i'm missing?

like image 781
Neversaysblack Avatar asked Mar 07 '14 02:03

Neversaysblack


People also ask

Can I download Google Play for free?

Google PLAY comes installed by default on most Android devices, but you can also download it from app stores like Uptodown.


1 Answers

Try this:

 playVideo.Timing.TriggerType = PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious;
like image 168
mohsen.asmand Avatar answered Oct 17 '22 07:10

mohsen.asmand