Using JS to toggle mute audio / button change state when advancing to next slide

Feb 10, 2023

I have a custom audio button on my master slide that when clicked will mute and unmute the audio using some js code I got from this forum.

It works just fine, except when I mute the audio and then advance to the next slide, the button state doesnt still show it as muted. I creating a t/f variable and then created an action that says set the variable to true if the audio is playing and false if the audio is muted but when I advance to the next slide it doesnt seem to be work. I need to also make sure it stays in the same state when I go backwards through the course as well. Can someone point me in the right direction.

Course snippet attached

5 Replies
Jose Tansengco

Hello Shawna, 

Thanks for reaching out!

I took a look at your project file and saw that your audio icon is using the built-in 'Selected' state to show that the volume is muted. The built-in 'Selected' is a state that exists only for an object on a slide, and doesn't get carried over to a different slide. This means that when your learners navigate to a different slide, the state of the audio icon is reset. 

To make the state change more permanent, try using variables to keep track of what the state of the audio icon should be. A true/false variable can help you keep track of which state the audio icon is in across all of your slides. 

Shawna Gigs

Hey Joe, thanks for you email.

I actually do have a variable and actions set up. They are in master slide. Maybe because they are in the master they arent working?

I have a variable called MuteAudio set to false

I set the state of Soundon (the audio button) to normal when the timeline starts if MuteAudio is set to True

Set Soundon to selected when timeline starts if MuteAudio is set to false

I also set MuteAudio to value of true Soundon is Normal and set to false when Soundo is selected.

I have all of this set up in the master slide but its still not working for me 

Walt Hamilton

Jurgen's method will work. The reason your triggers don't is that selected (like most of us) considers itself to be Normal. in fact, all the built-in states are considered to be normal states. Your trigger would probably work if you changed  "equal Normal" to "not equal Selected", but Jurgen's way is more elegant, and requires fewer triggers and less work.