Looping one single audio track throughout all slides

Hello heroes! Please rescue me from my idiocy!

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. 

Thank you.

6 Replies
Steve Flowers

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

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

    }

});

}