title: HTML5 duration time of MP3 sometimes works
body: <p>I'm having problems showing the duration time of an MP3 file in my HTML5 audio player. Sometimes it will load the duration time, sometimes it won't.</p>
  
  <p>The times it doesn't load is when I'm making changes to the CSS and when I refresh the page. </p>
  
  <p>When I change the MP3 file to load another MP3 file, the duration time shows up. It goes away when I refresh the page.</p>
  
  <p>This is the code for duration time:</p>
  
  <pre><code>audio.addEventListener('loadedmetadata', function(){
    progress.setAttribute('max', Math.floor(audio.duration));
    duration.textContent  = toHHMMSS(audio.duration);
  });
  </code></pre>
  
  <p>I'm new at JavaScript so I have no idea how to code. I'm using this code from <a href="https://codepen.io/davatron5000/pen/uqktG" rel="nofollow noreferrer">https://codepen.io/davatron5000/pen/uqktG</a> and when you refresh the page, the duration of mp3 file disappears. </p>