Forum Discussion
Custom Mute Unmute button
I am creating an e-learning where i have included a custom mute/unmute button, its working fine.
but the problem arises when i mute the audio on one slide and goes to next slide, what happens is - audio is still mute but the button's state shows its playing.
I have two buttons i.e. Audio On and Audio Off.
if being on a slide i mute the audio and moves to another slide, the audio is not playing but the button that is visible is "Audio on"..
please help on how can i fix this.. its an urgent request.
- PhilMayorSuper Hero
Add a variable T/F call it audio
set trigger on the custom mute button to toggle trigger add a trigger to change the state of the button on timeline start if audio is equal to true
- AshAtkinsonCommunity Member
- ShawnaGigacz-47Community Member
I have the same problem.
I have some js on my mute/unmute button(uses states) on my master slide that works great. I added a variable called muteAudio that I set to true. When the audio button is set to mute (selected state) I set the variable to false and when clicked again to turn audio back on, It sets the variable to true. I then have 2 actions that say when timeline starts and yu variable is true, set the Audio button to normal (unmuted) and when variable is set to false, set the audio button to selected (muted) but I when I go to the next slide, the Audio button always goes back to normal. Does anyone have a working example of how to get this to work?
- EricStavney-815Community Member
I might have a working example for you. Here's the logic that I use. I apologize if this isn't as focused on your question exactly.
I use a varAudioOn variable set to true and an Audio Button object with 3 states (on, off, down).
In the Triggers, I first have each slide check the status of the audio button when the slide begins, and then set the correct state or appearance of the button. Here's the logic:
1) If the audio was "on" for the previous slide, it should be audible on this one.
2) If the audio button state was in the OnState, then make the "Audio button" state on this slide to show the "on" state.
3) If the audio state on previous slide was "normal" = off, then show the off-state as this slide begins.
For controlling the varAudioOn variable, I have these trigger sets:
After these triggers, there's the usual two triggers (not shown) for moving to the next slide with Next and the previous slide with Previous.
Inside the "Execute Javascript" (click on this link) you'll find this Javascript snippet that toggles the audio from audible to mute and back. I don't understand how this code works, but it does.
//mute/unmute
// Use the global DS object if it exists, otherwise try require:
varappState = window.DS ? DS.appState : require("helpers/appState");
appState.onToggleVolume();
-----------------------------------------
I'm attaching a zip file of a demonstration of how the button works for me.