My Office 365 PowerPoint presentation has a single slide. The slide includes a shape with embedded (not linked, not OLE) video which I originally inserted from an .mp4 file. The video starts playing when I click on it but I need to control it from VBA code. Nothing I've tried (see below) works and of course I get no error messages or any kind of feedback. How do I start (and stop) the video from code?
Sub PlayVideo(Name)
Set Shape = GetShape(Name)
' Shape.MediaType == ppMediaTypeMovie
With Shape.AnimationSettings
.Animate = msoTrue
.AdvanceMode = ppAdvanceOnTime
.AdvanceTime = 0
.TextLevelEffect = ppAnimateByAllLevels
With .PlaySettings
.PlayOnEntry = msoTrue
.PauseAnimation = msoFalse
.LoopUntilStopped = msoTrue
End With
End With
With Slide.TimeLine.MainSequence
Set AnimationEffect = .AddEffect(Shape:=Shape, effectid:=msoAnimEffectMediaPlay)
With AnimationEffect
Set Behaviour = .Behaviors.Add(msoAnimTypeCommand)
With Behaviour
.CommandEffect.Type = msoAnimCommandTypeVerb
.CommandEffect.Command = "play"
End With
End With
End With
End Sub
To start the video use
SlideShowWindows(1).View.Player("algorithm panel").Play
To stop the video use
SlideShowWindows(1).View.Player("algorithm panel").Stop
Here is an example. Paste this in a module. My video name is SAMPLE.mp4
Option Explicit
Sub StartVideo()
SlideShowWindows(1).View.Player("SAMPLE").Play
End Sub
Sub StopVideo()
SlideShowWindows(1).View.Player("SAMPLE").Stop
End Sub
Next insert 2 action button in the slide and assign the macros
And we are done.