Forum Discussion
Stop audio when javascript typewriting effect stops
I found out a solution.
By using a variable that stops the sound when changed to true I could use javascript to change the variable instead.
The variable change trigger approach is the simplest.
Beyond that, despite what your sample code suggests, there is no StopAudio() function available in standard Storyline. Also, audio clips cannot be referenced directly by name.
Audio objects can be controlled via JavaScript as described here:
https://www.w3schools.com/jsref/dom_obj_audio.asp
You can create an array of all the audio clips on your slide using something like:
const audio = document.querySelectorAll("audio");
You can then use audio[0].play() or audio[0].pause() to play or pause the first available clip.
All of the audio clips are inserted into the slide without any easily accessible identifiers. The src attribute is likely derived from the sort-of-hashed original filename, the frequency, and the bit rate. In theory, you could derive the src string yourself and use it to match to one of the available clips in the audio array. The details for this are complicated and described in another post.