PDA

View Full Version : [SOLVED:] Using If/Then statements to play audio clips



albino_pygmy
08-12-2015, 07:33 AM
I've searched around and there's nothing that was clear or easy for me to apply to my projects. What I'd like to accomplish is when I click on a shape to reveal a score, it will play a ding sound. If the score is 0, then a buzzer sound would play instead. Another project would be click a button to change font color for text boxes, play a ding sound. If it couldn't find any text to change, play a buzzer. If this is all possible, would you be able to provide some code for me to adjust and apply to my projects? Thanks for your time!

John Wilson
08-12-2015, 01:40 PM
Try adding shapes to the slide master named "ding" (they can be invisible - no line transparent fill or just of slide)

As an example use Insert > Action to add a ding sound on click

You can play this from code


Dim oshp As Shape
Set oshp = ActivePresentation.SlideMaster.Shapes("ding")
oshp.ActionSettings(ppMouseClick).SoundEffect.Play

Should be easy to adapt to If / Then situations

albino_pygmy
08-13-2015, 06:42 AM
Works like a champ, and much more manageable. Thanks, John!

Kellaroo
03-23-2022, 09:26 PM
Great method !
Helped me too, Thanks.

ananyaa
04-04-2022, 02:18 AM
Try adding shapes to the slide master named "ding" (they can be invisible - no line transparent fill or just of slide)

As an example use Insert > Action to add a ding sound on click.
(https://gbofficial.net/gbwhatsapp-apk-download/)
You can play this from code

Dim oshp As Shape
Set oshp = ActivePresentation.SlideMaster.Shapes("ding")
oshp.ActionSettings(ppMouseClick).SoundEffect.Play

Should be easy to adapt to If / Then situations

Thanks a lot it worked.

Robert2
09-20-2023, 04:41 AM
I've searched around and there's nothing that was clear or easy for me to apply to my projects. What I'd like to accomplish is when I click on a shape to reveal a score, it will play a ding sound. If the score is 0, then a buzzer sound would play instead. Another project would be click a button to change font color for text boxes, play a ding sound. If it couldn't find any text to change, play a buzzer. If this is all possible, would you be able to provide some code for me to adjust and apply to my projects? Thanks for your time!

Certainly!
It sounds like you're interested in adding interactive elements to your projects. Achieving these goals is definitely possible with programming. For the first project, you can use JavaScript to detect the score and play either a ding or buzzer sound accordingly. For the second project, you can change the font color and trigger the sound effect when a button is clicked. youtube vanced (https://youtubvanced.org/)