Javascript to MUTE audio?

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...

Patrice

133 Replies
Diarmaid Collins

Apologies for the delay in responding. Nicole has linked to an earlier part of this thread, but if you still aren't clear here is what I did. 

I created a basic audio button with an OFF state (selected). I placed it on the Master Slide because I wanted it to be applicable/accessible on every slide.

I attached a trigger to it to Execute Javascript - simply copied and pasted the code above into the javascript panel that opens up. This script works as a switch. Anytime it runs it either turns on or off the audio.

I also created a variable called MUTE_AUDIO just to monitor the state of the button, whether it was selected or normal. And I set it to TOGGLE, like a switch. This is basically giving the user a visual clue as to what is happening (if they can't hear it already :) ).

You can see that the only real use of the MUTE_AUDIO variable is to have Storyline check whether the Audio Button is switched on or off as each slide begins so it can change the state of the Audio Button accordingly. You don't want the button resetting to Normal if the user had clicked the audio to be off in an earlier slide.

I hope that wasn't overkill on the explanation. If you have any further queries do let me know.

Once again, my thanks to Lizzie Angell for the code. It really helped me out on a major build.

Diarmaid Collins

Hi Amit,

Not sure why things have changed for you. The code Lizzie supplied (and I mention above) still works. I published a module with it last week and it behaves as it should.

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