Forum Discussion
Need audio file to play throughout 2 slides
- 6 days ago
Hi K_Dingman!
On the Slide 3, you could add a trigger to pause or stop the Background Audio.
For a smoother, less abrupt transition, you could use a series of timed triggers to reduce the volume of the Background Audio to zero and then stop it. This would reduce the volume to 90% for instance.
Or you could let Javascript handle it, but Player.BackgroundAudioVolume can't be set via SetVar() because it's a built-in player property, not a regular Storyline variable.
To achieve this, you'd need to create a 'bridging' variable, say 'Bgd_Volume' with a starting value of 100, and trigger Player.BackgroundAudioVolume to match any changes to it, like so:Then, this JavaScript could gradually reduce the volume over 5 seconds:
var player = GetPlayer(); var duration = 5000; // 5 seconds in milliseconds var interval = 50; // Update every 50ms for smooth fade var steps = duration / interval; var currentVolume = player.GetVar("Bgd_Volume"); var decrement = currentVolume / steps; var fade = setInterval(function() { currentVolume -= decrement; if (currentVolume <= 0) { currentVolume = 0; clearInterval(fade); } player.SetVar("Bgd_Volume", Math.round(currentVolume)); }, interval);
This trigger would be used to stop your audio when the volume hits 0:And if the user ever goes back to Slide 1 without restarting the course, and you want the music to play again, these triggers on Slide 1 would reset everything:
Hope that helps!
Hi K_Dingman!
On the Slide 3, you could add a trigger to pause or stop the Background Audio.
For a smoother, less abrupt transition, you could use a series of timed triggers to reduce the volume of the Background Audio to zero and then stop it. This would reduce the volume to 90% for instance.
Or you could let Javascript handle it, but Player.BackgroundAudioVolume can't be set via SetVar() because it's a built-in player property, not a regular Storyline variable.
To achieve this, you'd need to create a 'bridging' variable, say 'Bgd_Volume' with a starting value of 100, and trigger Player.BackgroundAudioVolume to match any changes to it, like so:
Then, this JavaScript could gradually reduce the volume over 5 seconds:
var player = GetPlayer();
var duration = 5000; // 5 seconds in milliseconds
var interval = 50; // Update every 50ms for smooth fade
var steps = duration / interval;
var currentVolume = player.GetVar("Bgd_Volume");
var decrement = currentVolume / steps;
var fade = setInterval(function() {
currentVolume -= decrement;
if (currentVolume <= 0) {
currentVolume = 0;
clearInterval(fade);
}
player.SetVar("Bgd_Volume", Math.round(currentVolume));
}, interval);
This trigger would be used to stop your audio when the volume hits 0:
And if the user ever goes back to Slide 1 without restarting the course, and you want the music to play again, these triggers on Slide 1 would reset everything:
Hope that helps!
Related Content
- 8 months ago
- 1 year ago
- 7 months ago
- 1 year ago