Pergunta

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.

Foi útil?

Solução 2

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.

Outras dicas

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).
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top