Forum Discussion
Javascript to MUTE audio?
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
- AndrewHoskins-eCommunity Member
This is a crazy old post - has a feature to install a custom button that can mute audio ever been created?
Is there better javascript available yet to do this? It would really help me with a project.
- NicoleRalph-117Community Member
Hi there,
I've had success with this script.
** Volume JavaScript code
var appState = require("helpers/appState");
appState.onToggleVolume();//mute/unmute
console.log(appState.volumeToggle);Hope this helps.
Nicole
- AndrewHoskins-eCommunity Member
Thank you Nicole. How did you set up your triggers? I plan to attach it to an image on the master slide.
- NicoleRalph-117Community Member
Hello.
I no longer have access to the project - thought I did.
But, here is a link to the forum where the code and steps I used was sourced from. Hope it helps.
https://community.articulate.com/discussions/articulate-storyline/javascript-to-mute-audio?page=4
- AndrewHoskins-eCommunity Member
Thank you, this helps!
- amityunger-53b6Community Member
That's right.
It did work until the last update.
Anyone have a solution?- DiarmaidCollinsCommunity Member
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();
- amityunger-53b6Community Member
This works great!
Thank you very much! :)
- LindsayLutmanCommunity Member
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? - BenjaminGomezCommunity Member
Many thanks to all of you for this long and old post, it helps me a lot :)
- ChandraShekh842Community Member
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();//muteNot 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,
- SethDorrCommunity Member
Looking into this and wanting to do a button with narration switching between two languages and be able to disable the music audio track..
Am I asking for too much or is this something with button states that this JavaScript will work on? If it still works? Newest posts reporting it is broken.
- MathNotermans-9Community Member
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();