I have a PowerPoint 2013 slide show with automatically advancing slides and background music. Some of the slides are videos and I would like the music to pause at such slides and automatically resume after. I could only find out how to make the music stop after a certain number of slides, but could not find out anything about pause/resume. Is this possible to do through the menus, or only with VBA?
Thanks a lot. Iliya
If you haven't found any solution, you can try some VBA, using "MCISendString", an external API function from winmm.dll.
One thing you should be careful is that there can't be any space character in 'fileToPlay' string. You can automate playing and resuming the audio playing by using another function named OnSlideShowPageChange.
#If VBA7 Then
Declare PtrSafe Function mciSendString Lib "winmm.dll" Alias _
"mciSendStringA" (ByVal lpstrCommand As String, ByVal _
lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
#Else
Declare Function mciSendString Lib "winmm.dll" Alias _
"mciSendStringA" (ByVal lpstrCommand As String, ByVal _
lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
#End If
Sub OnSlideShowPageChange(SSW As SlideShowWindow)
Dim fileToPlay As String
Dim MCIAudio As Long
fileToPlay = Chr(34) & ActivePresentation.Path & "\test.mp3" & Chr(34)
Select Case SSW.View.CurrentShowPosition
Case 1:
'first, close the previous playing and open new and play
MCIPlay = mciSendString("close MyAudio", Nothing, 0, 0)
MCIAudio = mciSendString("open " & fileToPlay & " alias MyAudio", Nothing, 0, 0)
MCIAudio = mciSendString("play MyAudio", Nothing, 0, 0)
Case 2:
MCIAudio = mciSendString("pause MyAudio", Nothing, 0, 0)
Case 3:
MCIAudio = mciSendString("resume MyAudio", Nothing, 0, 0)
Case 4:
MCIAudio = mciSendString("stop MyAudio", Nothing, 0, 0)
End Select
End Sub
Sub OnSlideShowTerminate()
Dim MCIAudio As Long
MCIAudio = mciSendString("stop MyAudio", Nothing, 0, 0)
MCIAudio = mciSendString("close MyAudio", Nothing, 0, 0)
End Sub
In this example, On Slide 1, starts playing. On Slide 2, pauses Playing. On Slide 3, resumes Playing. On Slide 4, stops playing. When the slide show ends, stops playing.
(You know, OnSlideShowPageChange sometimes fails to initiate. If then, just insert any Active-X control on the first slide, which is a known workaround.)
Other MCISendString commands can be found here: https://msdn.microsoft.com/en-us/library/ms710815.aspx