I know it can be done, but I can't seem to find a way to loop one lonely audio background track throughout all the slides. Essentially, I want it to play once, then continue to loop until the person exits the file, not start again everytime they flip to the next slide.I reaaaallly don't want to have to copy 'n' cut each audio to each match each slide. I'm good at editing, but not that good haha!
I'm open to editing the HTML or creating a javascript trigger. All suggestions would be highly welcome.
I'm working up a tutorial and example that uses the Soundmanager javascript library to load and control audio with a JS trigger. It's a lot more complicated than Alex's solution but there are a couple of things I like about this method.
It doesn't require editing published files (no post-publish surgery)
It allows for some controls like jumping to a specific position, controlling loops, pausing from JavaScript, controlling volume, etc..
You can load and swap multiple tracks based on a trigger.
This uses a Web object to transport the Soundmanager library and all of the audio files. Right clicking the web object and selecting Open will launch the object and give you the UID in the URL string. This is employed in the loading JS. Here's an older version of the script for loading up and playing audio across slides.
//So we know where all of our library items and audio files are
I bundle up the audio files as well as the soundmanager dependencies in a single web object. It's just so I can transport them within the Story and not have to add stuff later. Hoping to get to finishing up the example and explanation this weekend.
6 Replies
Hi Gemma,
Everything you need to know about this is mentioned here.
Hope this helps,
Alex
I'm working up a tutorial and example that uses the Soundmanager javascript library to load and control audio with a JS trigger. It's a lot more complicated than Alex's solution but there are a couple of things I like about this method.
This uses a Web object to transport the Soundmanager library and all of the audio files. Right clicking the web object and selecting Open will launch the object and give you the UID in the URL string. This is employed in the loading JS. Here's an older version of the script for loading up and playing audio across slides.
//So we know where all of our library items and audio files are
this.oLocation="story_content/WebObjects/66vjsN26Fjn/";
//load the scripts dynamically into the head of the document
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);
}
//but we only want to add these once!
if(document.getElementById('soundman')==null){
add_script(oLocation+"script/soundmanager2-jsmin.js","soundman");
}
//create blanks for the sounds at the window level
window.sound1="";
window.sound2="";
window.sound3="";
function stopAll(){
if(sound1){
sound1.stop();
}
if(sound2){
sound2.stop();
}
if(sound3){
sound3.stop();
}
}
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.play({
onfinish: function() {
loopSound(sound);
}
});
}
function initSounds(){
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
}
});
}
Steve,
Your solution seems to be fantastic. Where does the webobject point to exactly?
Can't wait to see that tutorial!
I bundle up the audio files as well as the soundmanager dependencies in a single web object. It's just so I can transport them within the Story and not have to add stuff later. Hoping to get to finishing up the example and explanation this weekend.
Did you ever complete the tut?
Here's a prototype containing a working example : https://community.articulate.com/discussions/building-better-courses/demo-dynamic-fade-in-out-using-sm2-background-audio
This discussion is closed. You can start a new discussion or contact Articulate Support.