Forum Discussion
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
21 Replies
- SBP_IncCommunity Member
Code is accessing the Audio object. Does that object exist in the HTML5 published content? And is jquery library loaded to handle your selector calls? I'm guessing a few javascript errors are stopping things for starters
- SudhakarReddy-5Community Member
Hi Akash,
Did you find the solution for Mute/Unmute button in Storyline 3. If yes, can you please let us know.
Regards
S
- vishalagarwalCommunity Member
for 360 and storyline 3 use this code to toggle the audio on and off:
var appState = require("helpers/appState");
appState.onToggleVolume();//muteVishal Agarwal
- ReenaMittal-e9aCommunity Member
Hi,
This is not working when open the new tab.(if i mute the audio than open the new tab in this case audio is not unmute)
Please suggest.😩
- AkashJambhorkarCommunity Member
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/unmuteAny alternative solution for this?
Thanks
Akash
- vishalagarwalCommunity Member
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.
- NicoleRalph-117Community Member
Hello Vishal,
Is there a way perhaps to visually show the learner when mute is on or off? Perhaps an icon in a green colour for on and red for off?
Many thanks
Nicole
- vishalagarwalCommunity Member
Hi Nicole,
You can create a toggle mute/unmute button and give on that button.
It works.
- ChristianCuneoCommunity Member
Can this code be used as is to toggle the audio mute/unmute?
if (document.location.href.indexOf('html5') < 0) {
var player = GetPlayer();
player.SetVar("muteToggle",true);
} else {
var appState = require("helpers/appState");
appState.onToggleVolume();//mute
}
- ReenaMittal-e9aCommunity Member
Hi Christina,
Please use this code for audio mute & unmute in articulate storyline 3 & 360.
Mute:
var appState = require("helpers/appState");
appState.onVolumeChanged(0);Unmute:
var appState = require("helpers/appState");
appState.onVolumeChanged(0.8); - AkashJambhorkarCommunity Member
Hello all,
A month ago I updated storyline 360 and JavaScript no longer works for audio mute/unmute.
Published output works fine before the update, but those same courses after the update do not work properly.
Do anyone have solution for this?
- RenGomezStaff
Hi Akash,
Are you using jQuery with your JavaScript? To improve security for our customers, we removed jQuery from Storyline 360. You can still use it to write custom JavaScript. You'll just need to reference the jQuery library directly. Hope this helps!
- SheetalDeopu194Community Member
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- JanagiramanDCommunity Member
Hi Sheetal, thanks for the above script. Its working fine for me too; but my problem is:
- I mute the audio
- Navigate to anyother opened tab
- When I come back and try to unmute the audio, it doesn't work.
Can you please help me on this one. Or anyone in the community, please give your suggestion.
- RussLickteigCommunity Member
Love it! Thanks Sheetal!
- RajendraKordeCommunity Member
Hi Sheetal,
This code works fine when we launch the course. but when we mute the audio and resume the course the code was not working.