Forum Discussion

JeffreyRiley-9e's avatar
JeffreyRiley-9e
Community Member
2 months ago
Solved

Use Javascript to toggle sound

Does anyone have suggestions for using javascript to toggle sound on and off in a course? Specifically looking to use text to speech and then give the participant the ability to listen to or no listen to the voice on the slide. I have been doing this with triggers but would javascript be better of give me more control?

5 Replies

  • I just tried it and it works the way I want. Thanks for the heads up. I also follow NRZ Malik so I am not surprised it works!

  • JoeFrancis's avatar
    JoeFrancis
    Community Member

    Several years back I started with this conversation (which links to another conversation) , because I need the volume of a looping audio file to gradually increase at certain points in an activity, until it was at 150%:

    Turning ON or OFF ALL audio in Storyline by using Javascript functionality on a button | Articulate - Community 

    First, I retrieved the current value from volumeSlider and parked that for later. At the same time, I set a new variable's value, decVolume, to 0.05. Then, I increased decVolume in JavaScript, and fed that into the course using SetVar. Once the activity was complete, I reset volumeSlider to its original value.

    In theory, you could set decVolume to 0.00, which should mute the audio. It would still play, but nothing would come out of the speakers.

    • JeffreyRiley-9e's avatar
      JeffreyRiley-9e
      Community Member

      JoeFrancis, thanks for the reply and I will look this over. I also used ChatGPT to give me a javascript that would work and it did.