Java script for MUTE/UNMUTE audio in Storyline 3

Hello All,

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

In the previous version of the storyline (Storyline 2), I am using javascript code to set the volume to 0 (mute audio) and set the volume to 0.8 (unmute audio). But now in storyline 3, the code was not working.

Please have a look on to the code which I used in Storyline 2:

"
Audio off button:
if (document.location.href.indexOf('html5') < 0) {
} else {

var player = GetPlayer();
Audio.setMasterVolume(0);
$('audio').prop('volume','0');
}
Audio on button :
if (document.location.href.indexOf('html5') < 0) {
} else {

var player = GetPlayer();
Audio.setMasterVolume(0.8);
$('audio').prop('volume','0.8');
}
"
It seems that in storyline 3 function is not working.

Has anyone an idea how audio is played in Storyline3? And how to mute/unmute audio like in Storyline 2?

Thanks
Akash

17 Replies
Akash Jambhorkar

Hello all,

In storyline update 5 Audio mute/unmute JS code is not working for video.

We use below mention code for audio mute/unmute in SL3 and SL360.

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

Any alternative solution for this?

Thanks

Akash

 

 

 

vishal agarwal

Hi Akash,

Use below code with condition this will work:

if (document.location.href.indexOf('html5') < 0) {
var player = GetPlayer();
player.SetVar("muteToggle",true);
} else {
var appState = require("helpers/appState");
appState.onToggleVolume();//mute
}

I am using this in my current course and this is working with me.

Sheetal Deopurkar

Hi Akash, here is the solution you are looking for. Try following code to mute/unmute audio.

//To mute audio add following Code

var appState = window.DS ? DS.appState : require("helpers/appState");
appState.onToggleVolume(0); //mute

 //To unmute audio add following Code

var appState = window.DS ? DS.appState : require("helpers/appState");
appState.onToggleVolume(1); //unmute

 

Cesar Carranza

Hi Sheetal, thanks a lot for your code, works like a charm it really does the job. I only have one mute/unmute button so I made a little change, now it works with the same button.

var appState = window.DS ? DS.appState : require("helpers/appState");
if (appState.onToggleVolume === 0){
appState.onToggleVolume(1);
}
else{
appState.onToggleVolume(0);
}