游戏和放大器;从表单控件的winform暂停视频 [英] Play & Pause Video from form control winform

查看:290
本文介绍了游戏和放大器;从表单控件的winform暂停视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打一个表单控制,能够启动,暂停,停止,关闭竞猜presentation(倒计时时间将运行在启动时为pressed)。问题是,在一些presentations,有可用的视频(每张幻灯片只能包含最多1个视频,而不是每一个幻灯片包含它)。

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

这些都是一些code段我在用于添加视频创造presentation 方法:

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

到目前为止,我已经尝试过此<一一些解决方案href="http://stackoverflow.com/questions/4428900/autoplaying-a-movie-in-a-powerpoint-$p$psentation-with-c-sharp">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:

无效的参数不能转换   Microsoft.Office.Interop.PowerPoint.Slide到   Microsoft.Office.Interop.PowerPoint.Shape

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

我要实现的目标是一个表单控件,可以播放视频时,用户presses启动按钮(倒计时运行)不自动播放幻灯片运行时。

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.

更新

我想这一个。该程序可以运行没有错误,但视频仍然不是在玩。

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


更新 @jonPall


UPDATE @jonPall

我想这一个:

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;

我的程序可以无错运行,但是当我preSS启动(播放视频和放大器;运行倒数计时器),它是给错误

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.

更新 @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;
    }
}

与上面的脚本,我可以检测,如果在活动幻灯片包含视频或不
但VAR〜〜的playVideo在幻灯​​片还是空包含视频 - 在那里我失踪?

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?

推荐答案

试试这个:

 playVideo.Timing.TriggerType = PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious;

这篇关于游戏和放大器;从表单控件的winform暂停视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆