Forum Discussion
Javascript to MUTE audio?
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();