title: Can't avoid delay in javascript audio
body: <p>I wonder whether this is an unresolved issue or not.</p>
  
  <p>OK, so I have this very simple test code:</p>
  
  <pre><code>var audio = new Audio("0.mp3");
  audio.oncanplay = function() {
      audio.play();
      setTimeout(function() {
          audio.pause();
      }, 30);
  }
  </code></pre>
  
  <p>What I intend to do is to play my sound for a very short period of time.<br>
  I know for sure that the audio (a middle-C note) starts in 0:00:00.<br>
  Note that I use the <code>oncanplay</code> event to make sure the audio is loaded when I try to play it.</p>
  
  <p>The problem I have is that I get unpredictable results. Sometimes <em>(most of the times, really)</em>, audio is not heard at all. Other times, audio <em>is</em> heard but not always for the same period of time.</p>
  
  <p>I know that Javascript can be slow, but I wonder, for example in the first case, why is the <code>timeout</code> set at all if the audio isn't playing yet.</p>
  
  <p>Is this a known issue? It is possible to have a better control over Audio?</p>
  
  <p>-<em>Thanks</em></p>