Forum Discussion
Audio on States - is there a way to stop it
- 9 months ago
Try creating a T/F variable called togAudioPauseAll.
Then create an Execute JavaScript trigger and inserting the following code:
const audioList = document.querySelectorAll("audio");
for (let i = 0; i < audioList.length; i++) { audioList[i].pause(); }
Set this trigger to fire when togAudioPauseAll changes.
Whenever the user clicks a new box/button/whatever, use an Adjust Variable trigger to toggle togAudioPauseAll.
This should stop all playing audio on the slide. Doing this before playing another audio clip lets you kill whatever audio is playing before the new one starts. It avoids having to create a bunch of individual triggers.
Try creating a T/F variable called togAudioPauseAll.
Then create an Execute JavaScript trigger and inserting the following code:
const audioList = document.querySelectorAll("audio");
for (let i = 0; i < audioList.length; i++) { audioList[i].pause(); }
Set this trigger to fire when togAudioPauseAll changes.
Whenever the user clicks a new box/button/whatever, use an Adjust Variable trigger to toggle togAudioPauseAll.
This should stop all playing audio on the slide. Doing this before playing another audio clip lets you kill whatever audio is playing before the new one starts. It avoids having to create a bunch of individual triggers.
- CarrieMaddern-a8 months agoCommunity Member
Thank you for sharing this Nathanial! Solved the problem for me.
- SuzanneNeafus4 days agoCommunity Member
Many months delayed - but this worked for me. I have a programming background - so using code was not an issue. Thank you!