Forum Discussion

ShawnaGigacz-47's avatar
ShawnaGigacz-47
Community Member
3 years ago

Muting Audio when course starts

I am using the code:

//mute/unmute
// Use the global DS object if it exists, otherwise try require:
var appState = window.DS ? DS.appState : require("helpers/appState");
appState.onToggleVolume();

on a custom mute/unmute button and it work great, but I want the audio file to automatically be muted when the course first starts. The user would have to click to turn the mute button off to listen to the audio. Is this something that has to be done in js?

  • Hi Eric,

    Thank you for your suggestion. This will come in handy for some other project I am working on, however for this one I do need to mute the audio, not stop the audio and then start the audio from the beginning again. 

    I'm hopeful there is an easy piece of javascript that I can add that will mute the audio on load. 

  • I'm happy to help, Shawna! Glad to hear the suggested solution is useful for your other projects! I hope our JavaScript experts in the community can chime in with their recommendations.

    Enjoy the rest of your day!

  • this are the possible command to change the audio level

    DS.appState.onToggleVolume();
    DS.appState.currentVolume() // get sound volume [0 ... 1]
    DS.appState.setVolume(value) // set sound volume value: [0 ... 1]
    DS.appState.lastVolume // get value: [0 ... 1]

    you can mute audio with

    DS.appState.setVolume(0)

    and set to the default player audio level with

    DS.appState.setVolume(0.75) 

    you don't need ... require("...") - this was for earlier storyline versions

    • CarolDawson's avatar
      CarolDawson
      Community Member

      Thank you so much! This is a perfect solution to meet my need.