Forum Discussion
JacksonHamner
10 years agoCommunity Member
Background Music Demo
I made a demo featuring background music that goes through the whole course (doesn't change from slide to slide). The user can chose from four songs to listen to and can adjust the volume, and the s...
DietmarGrasböck
9 years agoCommunity Member
Thanks to Jackson and as well all others for sharing this wonderful post :)
I needed to play an intro song at the first few slides which later stops at a certain slide. So I removed the loop
in the HTML5 <audio> tag.
<audio src="song.mp3" id="bgSong" preload="auto" autoplay></audio>
And, as I dont liked the abrupt ending of the song, I made a smooth fade-out with a javascript trigger:
var sound = document.getElementById('bgSong');
var fadeAudio = setInterval(function () {
// Only fade if not at zero already
if (sound.volume != 0.0) {
sound.volume -= 0.1;
}
// When volume at zero stop all the intervalling
if (sound.volume === 0.0) {
clearInterval(fadeAudio);
}
}, 400);
This works fine for me, but - to be honest - there is one thing, that bothers me. The Volume slider in the Storyline player has no influence to the <audio> song.
My question: Is there a way to forward the current level of the volume slider into other javascript variables?
I am grateful for any advice!
Regards,
Dietmar