title: How to add a setTimeout to a Random MP3 List
body: <p>The following script works well on a web page to randomize the MP3s that play from the list below, but I would like the MP3s to start playing at about ten seconds later, after page load, with a setTimeout.
  How is it done correctly? </p>
  
  <p>The following script works well on a web page to randomize the MP3s that play from the list below, but I would like the MP3s to start playing at about ten seconds later, after page load, with a setTimeout.
  How is it done correctly?    </p>
  
  <pre><code>&lt;script&gt;
      var audio; 
      var playlist; 
      var tracks; 
      var current; 
      var musicarr = [
  
      "After the Sun.mp3",
      "Dreamlight.mp3",
      "Shadows of the moon.mp3",
                     ];    
  
      shuffle(musicarr);
  
      init();
      function init(){
          current = 0;
          audio = $('audio');
          audio[0].volume = .7;
  
          len = musicarr.length;
  
          run(musicarr[current], audio[0]);
  
          audio[0].addEventListener('ended',function(e){
              current++;
              if(current == len){
                  current = 0;
              }
              run(musicarr[current],audio[0]);
          });
      }
  
      function run(link, player){
              player.src = link;
              audio[0].load();
              audio[0].play();    
      }
  
      function shuffle(array) {
        var currentIndex = array.length, temporaryValue, randomIndex ;
  
        // While there remain elements to shuffle...
        while (0 !== currentIndex) {
  
          // Pick a remaining element...
          randomIndex = Math.floor(Math.random() * currentIndex);
          currentIndex -= 1;
  
  
          // And swap it with the current element.
          temporaryValue = array[currentIndex];
          array[currentIndex] = array[randomIndex];
          array[randomIndex] = temporaryValue;
        }
  
        return array;
      }
  
      &lt;/script&gt; 
  </code></pre>