madhatter160
madhatter160

Reputation: 449

Setting Audio to Play Automatically in a PowerPoint Slide Affects Animations

Using VSTO and PowerPoint 2010, I am trying to insert an audio file into a PowerPoint slide and get it to play automatically when the slide is displayed. I got this far with the code below:

var presentation = Gobals.ThisAddIn.Application.ActivePresentation;
var slide = presentation.Slides[1];
var audioShape = slide.Shapes.AddMediaObject2( audioFilePath );
var audioShape.AnimationSettings.PlaySettings.PlayOnEntry = Microsoft.Office.Core.MsoTriState.msoTrue;

Now, In the slide there are already animations (represented by Effect objects) for bullet points. There is one Effect object for each bullet point. My add-in converts them from being triggered by on click to running automatically. This is accomplished with code similar to the following:

var effect = slide.TimeLine.MainSequence[1];
if ( effect.Timing.TriggerType == PowerPoint.MsoAnimTriggerType.msoAnimTriggerOnPageClick )
{
   effect.Timing.TriggerType = PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious;
   effect.Timing.TriggerDelayTime = delay;
}

The ultimate goal with the bullet point animations is to have each one be displayed separately after a certain delay.

My problem lies in setting the audio shape's to start automatically. This causes the separate Effect objects for each bullet point to be replaced by one Effect for all the bullet points. So, that all the bullet points are displayed on the screen at once rather than with a delay in between them. It doesn't matter if I insert the audio first or modify the bullet effects first.

There's got to be a way to set the audio to play automatically with out messing up the other Effects since you can do it in the GUI. Can anyone help? Thanks in advance.

Upvotes: 2

Views: 691

Answers (1)

Ayulin
Ayulin

Reputation: 2700

(Apologies if this is better suited as a comment - I don't have the ability to add those yet. I also realise this question is rather dated now.)

I just ran into a similar issue: after setting any of the PlaySettings properties, all the exit animations on my slides would be removed, and all animations set to "With Previous" became "After Previous" instead.

I came across this link, which indicates that the AnimationSettings object is a holdover from older versions of PowerPoint, and can mess things up in newer ones. More specifically,

If you use the AnimationSettings object in the new version to set any animation property, Microsoft PowerPoint will delete all animations which were not supported in the earlier versions from the animations that were already set on the slide.

(The link talks about XP/2003 as the "new version", but this behaviour seems consistent even in 2013.)

Essentially, setting the audio settings through AnimationSettings.PlaySettings triggers the removal of animations that weren't available in older versions of PowerPoint. Unfortunately, there doesn't seem to be another way of doing so.

Upvotes: 1

Related Questions