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
- NiteshKumar-34eCommunity Member
if (document.location.href.indexOf('html5') < 0) {
} else {var player = GetPlayer();
Audio.setMasterVolume(0);
$('audio').prop('volume','0');
}Above code is not working in storyline 360. Please suggest what can i do to mute the audio.
- LizzieAngellCommunity Member
for 360 use this code to toggle the audio on and off:
var appState = require("helpers/appState");
appState.onToggleVolume();//mute(I can't take credit for this - a guy I work with figured it out)
- bigtimeCommunity Member
I have been struggling with this issue for some time. This is a perfect solution. I can use the control in the master slide.
Thanks, Lizzie for posting and "the guy" for figuring it out.
- LizzieAngellCommunity Member
I have now found a slight issue with this in that if you click away from the tab, WHILE THE AUDIO IS OFF and then click back the javascript no longer executes - the audio will not switch back on.
This is still mostly the best solution but I do not know how to fix this issue
- AloysiusDomnicCommunity Member
Hi Naku,
Can you please suggest how to add this 'lifesaver code' in Tuggle mute/unmute button.
It will be more understandable if you share SL file for an example.
- MarekMacionga-8Community Member
Hi!
This week I updated storyline 360 and Javascript no longer works.
Trainings published before the update are ok, but those after the update do not work properly.
Do you have a solution for this? - RHoisanCommunity Member
Dear Nigel, you are a life saver. I was looking to make my custom volume buttons work for quite some time.
This does the trick. Let's hope it will last for future Storyline updates...
DS.appState.onToggleVolume();
- ErnestoRaymundoCommunity Member
Thanks, Nigel! It works perfectly.
DS.appState.onToggleVolume();
- DiarmaidCollinsCommunity Member
There has been no feature added to do this AFAIK, but Lizzie's solution above still works for me:
//mute/unmute
// Use the global DS object if it exists, otherwise try require:
var appState = window.DS ? DS.appState : require("helpers/appState");
appState.onToggleVolume();
- AndrewHoskins-eCommunity Member
Thank you. How did you set up your triggers?
- DiarmaidCollinsCommunity Member
Apologies for the delay in responding. Nicole has linked to an earlier part of this thread, but if you still aren't clear here is what I did.
I created a basic audio button with an OFF state (selected). I placed it on the Master Slide because I wanted it to be applicable/accessible on every slide.
I attached a trigger to it to Execute Javascript - simply copied and pasted the code above into the javascript panel that opens up. This script works as a switch. Anytime it runs it either turns on or off the audio.
I also created a variable called MUTE_AUDIO just to monitor the state of the button, whether it was selected or normal. And I set it to TOGGLE, like a switch. This is basically giving the user a visual clue as to what is happening (if they can't hear it already :) ).
You can see that the only real use of the MUTE_AUDIO variable is to have Storyline check whether the Audio Button is switched on or off as each slide begins so it can change the state of the Audio Button accordingly. You don't want the button resetting to Normal if the user had clicked the audio to be off in an earlier slide.
I hope that wasn't overkill on the explanation. If you have any further queries do let me know.
Once again, my thanks to Lizzie Angell for the code. It really helped me out on a major build.
- MarcRaskinski-3Community Member
Thank You! The other code offerings here did not work for me but yours (or Lizzie's?) did! Thanks!
- PatriceSigmonCommunity Member
Yep, I figured that much. What I'm hoping is that someone knows some Javascript I can use to build custom triggers for mute and unmute.
-phs
- PhilMayorSuper Hero
There is no exposed API so there is no way to mute the storyline player, you need access to a mute function in the player to do this using javascript.
TBH if Steve cannot do it, it cannot be done yet