Forum Discussion
Need audio file to play throughout 2 slides
- 27 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!
Hello Jonathan_Hill
I’ve just used your little JS code in my latest project to lower the background sound to 0 at the end of three introductory slides and just before a character starts speaking. It flows really well. AND I used the AI assistant to tweak this code so that the background volume goes back up to 100 on the last two slides of the module. So, thanks for this handy little thing, which I’m keeping in my toolbox, in the little drawer labelled ‘JonHill’ where there are already others.
NB: please ignore the “Approved” label, which appears to be a platform bug. Neither I nor anyone else has actually approved this message so far 😅.
Glad to hear it was helpful ThierryEMMANUEL 👍
Related Content
- 1 year ago
- 9 months ago
- 8 months ago
- 1 year ago