title: How can I play a short sound effect in a javascript app?
body: <p>I am finalizing the first version of my javascript app, and I would like to add sound effects. What is the recommended way to play a short sound (mp3 or wav or other format) using javascript in a web browser? I have ten sounds that I would like to have pre-loaded and able to play during application execution.</p>
  
  <p>I've created this small test app and can't get the audio to play. Maybe someone can show me where I'm going wrong:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Sound Test&lt;/title&gt;
      &lt;script type="text/javascript" src="raphael.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id="debugPane" style="width: 300px; height: 500px; float: left; background-color: #EEEEEE; margin-left: 10px; border-style: solid; border-width: 1px;"&gt;&lt;/div&gt;
      &lt;script type="text/javascript"&gt;
          try {
              var snd = new Audio("mp3/1.mp3");
              alert(snd.src);
              snd.play();
          } catch (err) {
              document.getElementById("debugPane").innerHTML += "" + err.message;
          }
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The correct file is being chosen. However, when I point to a file that doesn't exist, I don't get any exception. The file happily reports what its src is even though it's not actually on my filesystem.</p>