Mute audio using javascript

Feb 01, 2017

Hi guys,

i want to create my own mute/unmute audio button using articulate.i done this but i have a small problem.


i have three to four audio within a single slide.

when i click mute button from beginning of the timeline  and when my timeline reach audio 2 it get automatically play but my button is mute stage(selected).


15 Replies
Snorre Rubin

Hi Anitha

I would suggest that you add an extra variable, and another trigger:

In storyline add the variable "muted", which could be a true/false. Then use it in your code.

var player = GetPlayer();
var muted = player.GetVar("muted");
var a = document.getElementsByTagName('audio');
for(var i=0; i < a.length; i++)
if (a[i].volume>0)
player.SetVar("muted", true)
player.SetVar("muted", false)

This will tell set an custom variable which you can use to check if the use has chosen to mute the audio. 

Then for each audio piece, add an extra trigger to run at the same time as the next audio file starts with the following code:

var player = GetPlayer();
var muted = player.GetVar("muted");
if (muted)

This will check if the user has chosen to mute the audio, and remute if so.

Mark Spermon

The code Snorre has provided in this thread. Doesn't work in Storyline 360. I compared the code output for a Storyline 2 and a Storyline 360 module and it seems that in Storyline 360 they don't use the HTML audio element anymore to load audio files. 

So the javasccripts that are on the forum don't work anymore. 

Has anyone an idea how audio is played in Storyline360? And if there is a possibility to mute audio like in Storyline 2?



Sam Hill


This method uses vanilla JavaScript and so is future proof.

To mute all audio on the page (audio/video elements)

document.querySelectorAll("video, audio").forEach(elem => elem.muted = true);

And to unmute

document.querySelectorAll("video, audio").forEach(elem => elem.muted = false);

Jürgen Schoenemeyer

for audio it's not working, because storyline don't use html5 audio with a webserver and modern browser, storyline uses - if available - web audio

if you wan't html5 audio, you have to


window.AudioContext = null;
window.webkitAudioContext = null;


story.html + index_lms.html

or better at the end of the user.js

the two lines cannot be added to the internal storyline javascript - it's to late


Mateusz Szuter
Michael Anderson

Lizzie over here posted the solution. Make sure you visit the thread and thank her. Here's the code:

var appState = require("helpers/appState");

This should work always because it's Storyline's player function. It basically "clicks" the button from your player and make the training mute. All other options are overkill and unnecessarily complicated.

Jürgen Schoenemeyer

this stops working some years ago

the new methode is


and here some other nice functions

DS.appState.currentVolume()     // get sound volume [0 ... 1]
DS.appState.setVolume( value ) // set sound volume value: [0 ... 1]
DS.appState.lastVolume // value: [0 ... 1]

DS.appState.enterFullScreen(); // start fullscreen mode
DS.appState.exitFullScreen(); // exit fullscreen mode
DS.appState.toggleFullScreen(); // toggle fullscreen mode


DS.appState.setPlaybackSpeed( value );
Math Notermans

As Jurgen stated indeed...

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");

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");

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

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

LiG Playmakers Designer

This seems to work well: 

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

My challenge is that when users restart the course if the volume is toggled off it stays off and my speaker visual stops matching the sound. :/ 

Any ideas on how to turn the sound back on... 

I was thinking about having my reset button toggle the java script but the problem is if the sound is on it is now off and I have the same issue ... if that makes any sense... 


Here's the code you can either execute on the first slide or at the end to reset the volume to on.

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


There is probably a better javascript code you could use that is like 

getSound level if 0 set your sound variable to false

if 1 do nothing