Forum Discussion

PatriceSigmon's avatar
PatriceSigmon
Community Member
13 years ago

Javascript to MUTE audio?

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.

Dazed and confused...

Patrice

  • This is a crazy old post - has a feature to install a custom button that can mute audio ever been created?  

    Is there better javascript available yet to do this?  It would really help me with a project.

     

  • Hi there,

    I've had success with this script.

    ** Volume JavaScript code
    var appState = require("helpers/appState");
    appState.onToggleVolume();//mute/unmute
    console.log(appState.volumeToggle);

    Hope this helps.

    Nicole

    • AndrewHoskins-e's avatar
      AndrewHoskins-e
      Community Member

      Thank you Nicole.  How did you set up your triggers?   I plan to attach it to an image on the master slide.

    • DiarmaidCollins's avatar
      DiarmaidCollins
      Community Member

      Hi Amit,

      Not sure why things have changed for you. The code Lizzie supplied (and I mention above) still works. I published a module with it last week and it behaves as it should.

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

  • LindsayLutman's avatar
    LindsayLutman
    Community Member

    So appreciative of the 9 years of expertise that has been shared and preserved in this space! 

    This is almost the functionality I'm looking for, but I only need to mute select audio files (not videos), which means it cannot be tied to the audio controls already built into Storyline (i.e. keyboard commands/player controls). 

    Project Description: Slides and feedback layers are narrated and learners are able to turn on/off narration from a lightbox slide at any point during the course/module. Learners need to be able to use the player scrub bar to advance or rewind the narration so we're not able to trigger it using play/pause/stop. 

    Essentially, what we're looking to do is use JS to disable/enable the narration audio based on learners' changing preferences. Any recommendations?

  • BenjaminGomez's avatar
    BenjaminGomez
    Community Member

    Many thanks to all of you for this long and old post, it helps me a lot :)

  • Hi!, I am using Modern Player in 360 and trying to implement below JavaScript code for doing mute/unmute,

    var appState = require("helpers/appState");
    appState.onToggleVolume();//mute

    Not getting anything with this. In other term its not running for me. Could anyone have any idea for this? OR how do I add mute/unmute functionality for in modern player. 

    Thanks,

     

  • SethDorr's avatar
    SethDorr
    Community Member

    Looking into this and wanting to do a button with narration switching between two languages and be able to disable the music audio track..

     

    Am I asking for too much or is this something with button states that this JavaScript will work on? If it still works? Newest posts reporting it is broken.

  • Require is a Javascript library that doesnot work in newer browsers or might be added to the core in the newest Storyline updates. So you need to ensure not using it directly.

    var appState = require("helpers/appState");
    appState.onToggleVolume();//mute

    Above the first code years ago. This will not work nowadays anymore.
    When you however comment the first line and add DS ( for some Articulate internal stuff ) before appState it works fine.

    //var appState = require("helpers/appState");
    DS.appState.onToggleVolume();//mute

    So in later years someone used a ternary operator ( in fact an if/then check https://www.javascripttutorial.net/javascript-ternary-operator/ ) to check for DS or require availability and this works fine still.

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