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

Patrice

141 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();

Lindsay Lutman

So appreciative of the 9 years of expertise that has been shared and preserved in this space! 

This is almost the functionality I'm looking for, but I only need to mute select audio files (not videos), which means it cannot be tied to the audio controls already built into Storyline (i.e. keyboard commands/player controls). 

Project Description: Slides and feedback layers are narrated and learners are able to turn on/off narration from a lightbox slide at any point during the course/module. Learners need to be able to use the player scrub bar to advance or rewind the narration so we're not able to trigger it using play/pause/stop. 

Essentially, what we're looking to do is use JS to disable/enable the narration audio based on learners' changing preferences. Any recommendations?

Chandra Shekhar K

Hi!, I am using Modern Player in 360 and trying to implement below JavaScript code for doing mute/unmute,

var appState = require("helpers/appState");
appState.onToggleVolume();//mute

Not getting anything with this. In other term its not running for me. Could anyone have any idea for this? OR how do I add mute/unmute functionality for in modern player. 

Thanks,

 

Math Notermans

Require is a Javascript library that doesnot work in newer browsers or might be added to the core in the newest Storyline updates. So you need to ensure not using it directly.

var appState = require("helpers/appState");
appState.onToggleVolume();//mute

Above the first code years ago. This will not work nowadays anymore.
When you however comment the first line and add DS ( for some Articulate internal stuff ) before appState it works fine.

//var appState = require("helpers/appState");
DS.appState.onToggleVolume();//mute

So in later years someone used a ternary operator ( in fact an if/then check https://www.javascripttutorial.net/javascript-ternary-operator/ ) to check for DS or require availability and this works fine still.

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