Background Music in Storyline 2

I have seen threads here asking about background music when using Storyline 1 and all the advice points to doing a slight edit in the html code after publishing the file.

However, for the course I'm building, I don't want the background music to play until the user comes to the 2nd slide of the course. Is there anything in Storyline 2 that will allow me to do this? If not, do any of you have any advice of how I could do this?

Thanks in advance!

20 Replies
Steve Flowers

Hi Rachel - 

I've used SoundManager to pull off controlled audio. This will let you load audio in the background at will, pause, play, fade it in, etc.. Takes some figuring out.

I loaded the library in as a web object then dynamically loaded the library to the header with a JavaScript trigger. My load setup trigger looked like this. This was a test to see what could be done. It provides a way to load audio and loop in the background as well as change it out or stop the audio. Your setup may be a little different.

One of the reasons I like this setup is it doesn't require editing files after publish (no post publish surgery). Saves a step and all of the dependencies are saved with the story file.

//where is our carry-on baggage?this.oLocation="story_content/WebObjects/66vjsN26Fjn/";
//load the scripts dynamically
function add_script(scriptURL,oID) {
var scriptEl = document.createElement("script");
var head=document.getElementsByTagName('head')[0];
scriptEl.type = "text/javascript";
scriptEl.src = scriptURL;
scriptEl.id=oID;
head.appendChild(scriptEl);
}
//only want to add these once!
if(document.getElementById('soundman')==null){
add_script(oLocation+"script/soundmanager2-jsmin.js","soundman");
//grab the audio variable value and begin playing the loop on reload if it's not blank
}
window.sound1="";
window.sound2="";
window.sound3="";
window.stopAll=function(){
soundManager.stopAll();
}
window.play1=function(){
sound1 = soundManager.createSound({
id: 'sound1',
url: oLocation+'loop1.mp3'
});
stopAll();
loopSound(sound1);
}
window.play2=function(){
sound2 = soundManager.createSound({
id: 'sound2',
url: oLocation+'loop2.mp3'
});
stopAll();
loopSound(sound2);
}
window.play3=function(){
sound3 = soundManager.createSound({
id: 'sound3',
url: oLocation+'loop3.mp3'
});
stopAll();
loopSound(sound3);
}
function loopSound(sound) {
sound.setVolume(45);
sound.play({
onfinish: function() {
loopSound(sound);
}
});
}
window.initSounds=function(){
soundManager.setup({
url: 'swf/',
onready: function() {
// SM2 has loaded, API ready to use e.g., createSound() etc.
},
ontimeout: function() {
// Uh-oh. No HTML5 support, SWF missing, Flash blocked or other issue
}
});
}
Priyanka Sharma

Hi Rachel,

I think you should try this once. If you don't want the background music to play until the user comes to the 2nd slide of your course, just add the audio in second slide. The best practise is to add the audio for the particular slide. Below is the attachment that you can follow. I hope this will work for you.