Javascript to MUTE audio?

Aug 09, 2012

Is it possible to MUTE audio in Storyline? I'm working on a course with a ground-up custom interface with a button that's supposed to mute/unmute - not pause/play or stop/play - the audio.

Are there any Javascript gurus out there who know if this is possible? And if so, can you provide the scripts for mute and unmute? That would SO make my day.

Dazed and confused...


141 Replies
Dan Shannon

You say it won't work in "preview", which I take to mean the specific Preview mode available from the Slide interface.

So, here's what I need to know.

Will it work in any of the other ways that one would use to "preview", such as Review 360 or Web?

In some ways, either of these preview options could be considered a server, in a sense.

I tried both ways, though, and neither worked at all.

This is where providing a more thorough explanation would probably save time in the long run. 

As I've said, putting an eLearning on a server or LMS is actually a pretty big deal in my organization and I'd like to be able to test its functionality before I do that.

Thanks again.


Lizzie Angell

try this one  - it is definitely working for us in the latest SL - there is some issues with older browsers and the audio on off working - we think this one covers it:

// Use the global DS object if it exists, otherwise try require:
var appState = window.DS ? DS.appState : require("helpers/appState");


Diarmaid Collins

Hi Lizzie. Thanks for that code. It does the job perfectly apart from one small, tiny issue, and I'm hoping you may be able to help me.

I have an Audio button on the master slide with your code attached as an Execute Javascript, and it works.

My button has 2 states; Normal and Select. Normal has an icon with audio and Select has a mute icon. It works perfectly on the slide when clicked/toggled.

However, if the user has clicked the button for Mute (Select) and they move to a new slide, the button resets to Normal.

What part of your code snippet can I use to monitor if the audio is off and have the button set to Selected when a new slide timeline has started? Is "ToggleVolume" an observable item for Storyline to read from?

Apologies for the super long-winded way of asking how do I have a button remain on the mute state (selected) when moving through a module?

Lizzie Angell

Hi Diarmaid

For that you just need a separate variable that is true and false. 

Set it to be True (sound is on)

Set trigger to say toggle variable when user clicks the audio button

Then set another trigger to say: Set audio button to select when timeline starts if variable is false (audio off) 

You might also want one to say: Set audio button to normal if variable is true, when timeline starts - just to cover all bases. 

Diarmaid Collins

Excuse me for being a bit dense there. I was overcomplicating things. I simply had to create my own variable (MuteAudio) and add that to the button and set it to toggle. That way the module is able to 'monitor' the code you've provided and adjust the state on every new slide accordingly.