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.
Almost nothing to this. Just create a button and add an Execute javascript trigger. In the javascript panel of the trigger just add DS.appState.onToggleVolume();
That's all you need to do. It will not work in preview but will once it's on a server or LMS.
You say it won't work in "preview", which I take to mean the specific Preview mode available from the Slide interface.
So, here's what I need to know.
Will it work in any of the other ways that one would use to "preview", such as Review 360 or Web?
In some ways, either of these preview options could be considered a server, in a sense.
I tried both ways, though, and neither worked at all.
This is where providing a more thorough explanation would probably save time in the long run.
As I've said, putting an eLearning on a server or LMS is actually a pretty big deal in my organization and I'd like to be able to test its functionality before I do that.
As far as I know none of the javascripts in general works in preview. You have to publish the course either locally, review360 or LMS. Any javascript will work in published versions.
try this one - it is definitely working for us in the latest SL - there is some issues with older browsers and the audio on off working - we think this one covers it:
//mute/unmute // Use the global DS object if it exists, otherwise try require: var appState = window.DS ? DS.appState : require("helpers/appState"); appState.onToggleVolume();
Hi Lizzie. Thanks for that code. It does the job perfectly apart from one small, tiny issue, and I'm hoping you may be able to help me.
I have an Audio button on the master slide with your code attached as an Execute Javascript, and it works.
My button has 2 states; Normal and Select. Normal has an icon with audio and Select has a mute icon. It works perfectly on the slide when clicked/toggled.
However, if the user has clicked the button for Mute (Select) and they move to a new slide, the button resets to Normal.
What part of your code snippet can I use to monitor if the audio is off and have the button set to Selected when a new slide timeline has started? Is "ToggleVolume" an observable item for Storyline to read from?
Apologies for the super long-winded way of asking how do I have a button remain on the mute state (selected) when moving through a module?
Excuse me for being a bit dense there. I was overcomplicating things. I simply had to create my own variable (MuteAudio) and add that to the button and set it to toggle. That way the module is able to 'monitor' the code you've provided and adjust the state on every new slide accordingly.
I need to custom the audio button. i have one button it will mute the audio or unmute the audio. But i dont know the javascript. so please explain me in detail. I m working on SL360.
141 Replies
Same here. The scripts that I used last year are not working now.
Having the same problem. Getting an error "require is not defined" in the Developer Console. Any quick fix for this?
This has been working for me. Add to a javascript trigger:
DS.appState.onToggleVolume();
This post was removed by the author
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();
I'm new to JS, but want to learn.
Can someone take me through the process of writing the script for a toggle mute/unmute button?
Thanks, Nigel! It works perfectly.
DS.appState.onToggleVolume();
Hi Dan,
Almost nothing to this. Just create a button and add an Execute javascript trigger. In the javascript panel of the trigger just add DS.appState.onToggleVolume();
That's all you need to do. It will not work in preview but will once it's on a server or LMS.
Cheers,
Nigel
Hi,
Tried the solution today and it does not work in the latest version of storyline 360
Hi Nigel,
Putting a Storyline on the LMS is kind of a big deal in my organization.
Will it work on Review 360 or if I save the file folder to my computer?
I won't be insulted if you dumb it down.
Thanks,
Dan
You say it won't work in "preview", which I take to mean the specific Preview mode available from the Slide interface.
So, here's what I need to know.
Will it work in any of the other ways that one would use to "preview", such as Review 360 or Web?
In some ways, either of these preview options could be considered a server, in a sense.
I tried both ways, though, and neither worked at all.
This is where providing a more thorough explanation would probably save time in the long run.
As I've said, putting an eLearning on a server or LMS is actually a pretty big deal in my organization and I'd like to be able to test its functionality before I do that.
Thanks again.
Dan
Hello,
As far as I know none of the javascripts in general works in preview. You have to publish the course either locally, review360 or LMS. Any javascript will work in published versions.
Again JS does not work in preview.
Hope that helps.
I tried publishing locally and on Review 360 using Nigel's instructions.
Didn't work.
If you've been able to get the JS to work, could you please provide a procedure?
Thanks,
Dan
try this one - it is definitely working for us in the latest SL - there is some issues with older browsers and the audio on off working - we think this one covers it:
//mute/unmute
// Use the global DS object if it exists, otherwise try require:
var appState = window.DS ? DS.appState : require("helpers/appState");
appState.onToggleVolume();
Wow! It works!
Thanks,
Dan
OMG this is EXACTLY what I've been searching for!!
Hi Lizzie. Thanks for that code. It does the job perfectly apart from one small, tiny issue, and I'm hoping you may be able to help me.
I have an Audio button on the master slide with your code attached as an Execute Javascript, and it works.
My button has 2 states; Normal and Select. Normal has an icon with audio and Select has a mute icon. It works perfectly on the slide when clicked/toggled.
However, if the user has clicked the button for Mute (Select) and they move to a new slide, the button resets to Normal.
What part of your code snippet can I use to monitor if the audio is off and have the button set to Selected when a new slide timeline has started? Is "ToggleVolume" an observable item for Storyline to read from?
Apologies for the super long-winded way of asking how do I have a button remain on the mute state (selected) when moving through a module?
Hi Diarmaid
For that you just need a separate variable that is true and false.
Set it to be True (sound is on)
Set trigger to say toggle variable when user clicks the audio button
Then set another trigger to say: Set audio button to select when timeline starts if variable is false (audio off)
You might also want one to say: Set audio button to normal if variable is true, when timeline starts - just to cover all bases.
Excuse me for being a bit dense there. I was overcomplicating things. I simply had to create my own variable (MuteAudio) and add that to the button and set it to toggle. That way the module is able to 'monitor' the code you've provided and adjust the state on every new slide accordingly.
no worries - i think it is something we all do once we start looking at the complications of javascript!
Hi Lizzie. I didn't see that you had written your response hours ago!
Many thanks for your help. I am glad I was eventually able to figure it out for myself. I feel a little happier about being a little less thick! :)
Hi everyone,
I use this JS but its working on 18 august 2020 STL 360 version.
var appState = require("helpers/appState");
appState.onToggleVolume();//mute
Anyone have a solution for this issue.
Hi,
a colleague of mine helped me with this javascript :
var appState = window.DS ? DS.appState : require("helpers/appState");
appState.onToggleVolume();
I need to custom the audio button. i have one button it will mute the audio or unmute the audio. But i dont know the javascript. so please explain me in detail. I m working on SL360.
Also, i want to mute the audio of video file.