Forum Discussion

MarcoParenti's avatar
MarcoParenti
Community Member
4 years ago

how to create a sound volume button

Hi,

I want to know how to create a control volume button without using the default player.

Thankyou

 

  • MaiAbdelsalam's avatar
    MaiAbdelsalam
    Community Member

    This worked for me if anyone needs it 

    create excute javascript

    DS.appState.setVolume(1);//play sound

    DS.appState.setVolume(0); //mute 

  • This custom audioVolume slider works. Uses this code to set the audio.
    var allAudios = document.getElementsByTagName("audio");
    if (allAudios[0].volume >= 0) {
    for (var a = 0; a < allAudios.length; a++) {
    allAudios[a].volume = _volume;
    }
    }

  • EricPERON's avatar
    EricPERON
    Community Member

    Hello Katie,

    This is my first post too :-)

    i'm looking for the the same thing as Marco. I've tested your first solution. Does it work anymore  ?

    The tutorial say's to replace a file named "app.min.js" who doesn't  exist when i publish their storyLine sample. 

    Otherwise on Chrome, the sample generates a javaScript error (see attachment)

    i saw this post who says this file doesn't exist anymore in Storyline.
    Can you confirm this ?
    is there a replacement solution ?

    Thank's for your answer

    Eric

    P.S. : i don't publish in Scorm mode

  • In the browser this command works in your console...
    DS.appState.setVolume(0.2);

    I couldnot figure out (yet) how to make that work in Storyline as trigger...

  • EricPERON's avatar
    EricPERON
    Community Member

    Hello Math,

    Thank you for your example. It works fine !
    i try to do something with it

     

  • If you are comfortable with editing code in the exported files, you can also do the following...

     

    Search the ds-slides.min.js file for parseBlocks,i=DS,r=i._,s=i.utils (this file is minified, so make sure no spaces in the search term.  Then look just before for var e= and insert _c=DS.appState; before the var keyword.  So for example you will see this (the numbers in parenthesis may vary) var e=f(50),n=f(16).parseBlocks,i=DS,r=i._,s=i.utils and you will change it to _c=DS.appState;var e=f(50),n=f(16).parseBlocks,i=DS,r=i._,s=i.utils  

    You can then adjust the volume from within Storyline using a javascript trigger and calling _c.setVolume(number from 0 to 1).