title: How to play an audio file in a infinite loop using jQuery
body: <p>Right now I have a piece of code (below) which allows me to play audio files on button click. However, I would like to have the file playing in a infinite loop until I click click the button "Stop" button.
  How can I achieve that?</p>
  
  <pre><code>var audiotypes={
      "mp3": "audio/mpeg",
      "mp4": "audio/mp4",
      "ogg": "audio/ogg",
      "wav": "audio/wav"
  }
  
  function ss_soundbits(sound){
      var audio_element = document.createElement('audio')
      if (audio_element.canPlayType){
          for (var i=0; i&lt;arguments.length; i++){
              var source_element = document.createElement('source')
              source_element.setAttribute('src', arguments[i])
              if (arguments[i].match(/\.(\w+)$/i))
                  source_element.setAttribute('type', audiotypes[RegExp.$1])
              audio_element.appendChild(source_element)
          }
          audio_element.load()
          audio_element.playclip=function(){
              audio_element.pause()
              audio_element.currentTime=0
              audio_element.play()
          }
          return audio_element
      }
  }
  
  var audio = ss_soundbits('audio/file.mp3');
  
  var start_audio= function() {
     audio.playclip();
  };
  </code></pre>