title: seek bar handling with javascript on HTML5 audio tag
body: <p>I've my codes as below</p>
  
  <pre><code>&lt;header&gt;
      &lt;audio src="friends_and_family_03.mp3" id="audio" controls&gt;&lt;/audio&gt;
      &lt;input type="range" step="any" id="seekbar"&gt;&lt;/input&gt;
      &lt;script&gt;
          seekbar.value = 0;
          var audio = document.getElementById("audio");
  
          var seekbar = document.getElementById('seekbar');
          function setupSeekbar() {
            seekbar.min = audio.startTime;
            seekbar.max = audio.startTime + audio.duration;
          }
          audio.ondurationchange = setupSeekbar;
  
          function seekAudio() {
            audio.currentTime = seekbar.value;
          }
  
          function updateUI() {
            var lastBuffered = audio.buffered.end(audio.buffered.length-1);
            seekbar.min = audio.startTime;
            seekbar.max = lastBuffered;
            seekbar.value = audio.currentTime;
          }
          seekbar.onchange = seekAudio;
          audio.ontimeupdate = updateUI;
  
      &lt;/script&gt;
      &lt;p&gt;
          &lt;button type="button" onclick="audio.play();"&gt;Play&lt;/button&gt;
          &lt;button type="button" onclick="audio.pause();"&gt;Pause&lt;/button&gt;
          &lt;button type="button" onclick="audio.currentTime = 0;"&gt;&lt;&lt; Rewind&lt;/button&gt;
      &lt;/p&gt;
  
  &lt;/header&gt;
  </code></pre>
  
  <p>This is as explained in <a href="http://dev.opera.com/articles/view/everything-you-need-to-know-about-html5-video-and-audio/" rel="noreferrer">http://dev.opera.com/articles/view/everything-you-need-to-know-about-html5-video-and-audio/</a></p>
  
  <p>My problems are
  1) The seekbar max value is not set according to the audio duration. (The seekbar width is just around half the audio duration).
  2) The seekbar doesnt show any progress as the audio plays on but if you drag the seekbar, the currenTime actually changes.</p>
  
  <p>Can anyone help me modify my code so that it functions properly??</p>