PowerPoint SlideShowSettings.Run() 不运行嵌入视频

发布于 2024-09-06 04:33:48 字数 543 浏览 10 评论 0原文

我有一个 C# 应用程序,在连接到我们自助餐厅的大显示屏的计算机上运行。该应用程序将所有 PowerPoint 文件从文件夹中取出,并以幻灯片形式连续运行每个文件。一切都工作正常,直到有人决定将影片剪辑插入幻灯片上。问题是电影永远不会开始。如果在 PowerPoint 中打开演示文稿并运行该演示文稿,则它可以正常工作;如果我右键单击演示文稿并单击“显示”,则它可以正常工作。这是我用来打开演示文稿并开始幻灯片放映的代码。

pres = app.Presentations.Open(pptPath, MsoTriState.msoTrue, MsoTriState.msoTrue, MMsoTriState.msoFals);
pres.SlideShowSettings.Run();

我还需要设置其他内容才能让 Run() 方法也开始播放电影吗?

编辑:相关演示文稿中只有一张包含电影的幻灯片。如果我添加另一张幻灯片,效果就很好。之前也尝试添加幻灯片并遇到了同样的问题,所以显然问题只存在于演示文稿中的最后一张幻灯片。

I have a C# application that runs on a computer connected to a large display in our cafeteria. The application pulls all the PowerPoint files out of a folder and runs each one as a slide show continuously. Everything was working fine until someone decided to insert a movie clip onto a slide. The problem is that the movie never starts. If open the presentation in PowerPoint and run the show it works, and if I right click on the presentation and click 'show' it works. Here is the code I am using to open the presentation and start the slideshow.

pres = app.Presentations.Open(pptPath, MsoTriState.msoTrue, MsoTriState.msoTrue, MMsoTriState.msoFals);
pres.SlideShowSettings.Run();

Is there something else I need to set to get the Run() method to also start movies?

Edit: The presentation in question only had one slide in it which contained the movie. If I added another slide to it, it worked fine. Also tried adding a slide before and had the same problem, so apparently the problem only exists for the last slide in the presentation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风铃鹿 2024-09-13 04:33:48

这里的主要问题是 PowerPoint 动画(视频、音频、自定义运动路径等)仅在 SlideShowWindow 获得焦点时才会播放。这意味着,当您运行应用程序并启动 PPT 时,您的应用程序仍然保持焦点,因此动画不会运行(但这并不妨碍您手动操作运行面板)。

有几种方法可以解决这个问题:

  1. 您可以调用 API SetWindow
    将您的 SlideShowWindow 带到
    正面。这不是一个好方法
    我的意见。
  2. 最简单的方法就是保存
    您的 .ppt/.pptx 到 .pps/.ppsx
    (PowerPoint 演示)。有了这个,你
    可以使用相同的代码来运行它并且
    它将启动并成为焦点
    自动(并且您的动画[视频等)将按您的预期运行)。

The main issue here is that PowerPoint animations (video, audio, custom motion paths, etc.) will only play when the SlideShowWindow has the focus. What this means is that when you're running your app and launching PPT, your app still maintains the focus and hence animations don't run (that doesn't stop you from manually manipulating your running deck though).

There are a couple of ways around this:

  1. You can call the API SetWindow to
    bring your SlideShowWindow to the
    front. Not a great way to do it in
    my opinion.
  2. The very easiest way is just to save
    your .ppt/.pptx to a .pps/.ppsx
    (PowerPoint Show). With that, you
    can use your same code to run it and
    it will launch and take the focus
    automatically (and your animations [video, et al) will run as you've intended).
蒲公英的约定 2024-09-13 04:33:48

发现问题了。我在演示文稿的 app_SlideShowNextSlide 事件处理程序中有一个 thread.sleep 语句,用于处理一张幻灯片的结束并开始下一张幻灯片。我当时没有想到,这段代码在幻灯片本身的同一个线程中运行。我创建了一个计时器对象,并将必要的代码移至计时器的 elapsed 事件处理程序中。

Found the problem. I had a thread.sleep statement in the presentation's app_SlideShowNextSlide event handler that handled the end of one slideshow and starting the next. I wasn't thinking at the time and this code was running in the same thread at the slideshow itself. I created a timer object instead and moved the necessary code into the timer's elapsed event handler.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文