PowerPoint SlideShowSettings.Run() 不运行嵌入视频
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里的主要问题是 PowerPoint 动画(视频、音频、自定义运动路径等)仅在
SlideShowWindow
获得焦点时才会播放。这意味着,当您运行应用程序并启动 PPT 时,您的应用程序仍然保持焦点,因此动画不会运行(但这并不妨碍您手动操作运行面板)。有几种方法可以解决这个问题:
SetWindow
来将您的
SlideShowWindow
带到正面。这不是一个好方法
我的意见。
您的 .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:
SetWindow
tobring your
SlideShowWindow
to thefront. Not a great way to do it in
my opinion.
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).
发现问题了。我在演示文稿的
app_SlideShowNextSlide
事件处理程序中有一个thread.sleep
语句,用于处理一张幻灯片的结束并开始下一张幻灯片。我当时没有想到,这段代码在幻灯片本身的同一个线程中运行。我创建了一个计时器对象,并将必要的代码移至计时器的elapsed
事件处理程序中。Found the problem. I had a
thread.sleep
statement in the presentation'sapp_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'selapsed
event handler.