Storyline 360 custom volume control

Today I was asked by my colleague at work to help her out with fixing problem with custom volume control. She was using StoryLine 2 solution from this page but on Storyline 360. Following is the script from the SL2 solution:

var player = GetPlayer();
var volumeCount = player.GetVar('volumeCount')
Audio.setMasterVolume(volumeCount);

This worked on the courses exported from StoryLine 2 as the Audio object indeed has the setMasterVolume which is not true for StoryLine 360 courses. I’ve searched internet and failed to find anything about volume controls on SL360.
My colleague told me that SL has built in volume controls which work. I’ve enabled it and checked what has appeared in code (player-volume and control-volume-slider), then searched for it in output files. In the minified code I’ve found the currentVolume function which was something I hoped to get access to.

I’ve noticed that this method is wrapped with the define("helpers/appState"... so I’ve tried to retrieve it with require and succeeded


var appState = require("helpers/appState");
appState.currentVolume();//get
appState.currentVolume(0.5);//set

With this finding in hand it was now simple to modify the original code to work in SL360:

var player = GetPlayer();
var volumeCount = player.GetVar("volumeCount");
var appState = require("helpers/appState");
appState.currentVolume(volumeCount);

The SL2 example was using volumeCount property to make a division by 10 we can skip it and if we set up slider to be from start: 0 to end: 1 with step: 0.1 we can modify the script even further:

var player = GetPlayer();
var value = player.GetVar("volumeSlider");
var appState = require("helpers/appState");
appState.currentVolume(value);

Note: I have no prior knowledge of Storyline and I kind of hacked this solution, so if there is an “official” way to setup volume please let me know:)

EDIT:
I think better option for changing the volume will be to use the onVolumeChanged(value) callback method as it also updates the volumeToggle state.

If you want to have mute button functionality then use onToggleVolume() method.

var player = GetPlayer();
var value = player.GetVar("volumeSlider");
var appState = require("helpers/appState");
appState.onVolumeChanged(value);

To toggle audio:

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

to test current state of the audio

var appState = require("helpers/appState");
if(appState.volumeToggle) {
// audio muted
} else {
// audio unmuted
}
This entry was posted in JavaScript and tagged , . Bookmark the permalink.

5 Responses to Storyline 360 custom volume control

  1. Hassaan Ijaz Ud Din says:

    Hi, can this approach be used to change the volume of an imported video in storyline 360?

  2. Rick Maranta says:

    Hi. I am trying to access the currentTime of the audio on a slide and display it. Since you accessed the volume. Is there a way to access the current time and duration in Storyline 360?

    • Hi,

      I haven’t tried this, there is a slim chance that it is somewhere in code accessible and could be exposed like this volume hack. Dont have much time now so wont be able to check it myself.

      regards

  3. Alessandro says:

    Hello Lukacz, I am trying to use this script but as I change the position of the slider, instead to adjust the audio volume it mute my audio file!

    Any suggestion?

Comments are closed.