title: HTML5 audio duration for mp3 is always Infinity
body: <p>I'm playing with my pet project and, experimenting with mp3 "streaming" with PHP, I always get the audio duration to return <code>Infinity</code>. I've try to search in many places, unfortunately, I can't seem to find the root problem.</p>
  
  <p>Note that I had to put that project aside for a while, and everything worked fine before. When I restarted working on the project, I did some UI refactor and found out about this "bug". Can anyone spot something wrong with my code?</p>
  
  <p>Context : this is in a controller (ZF2) action, where <code>$media</code> is a <a href="http://www.javaleaks.org/open-source/php/plain-old-php-object.html" rel="nofollow"><em>POPO</em></a> model.</p>
  
  <pre><code>$file = $basePath . $media-&gt;getFileName();
  $fileSize = filesize($file);
  $fileHandle = fopen($file, 'r');
  
  $etag = md5(serialize(fstat($fileHandle)));
  $cacheExpires = new \DateTime();
  
  // TODO : implement ranges...
  if ( isset($_SERVER['HTTP_RANGE']) ) {
  
      // find the requested range
      // this might be too simplistic, apparently the client can request
      // multiple ranges, which can become pretty complex, so ignore it for now
      preg_match('/bytes=(\d+)-(\d+)?/', $_SERVER['HTTP_RANGE'], $matches);
  
      $rangeFrom = intval($matches[1]);
      $rangeTo = intval($matches[2]);
  
      $statusCode = 206;
  } else {
      $rangeFrom = 0;
      $rangeTo = $fileSize;
      $statusCode = 200;
  }
  
  fseek($fileHandle, $rangeFrom);
  
  set_time_limit(0); // try to disable time limit
  
  $response = new Stream();
  $response-&gt;setStream($fileHandle);
  $response-&gt;setStatusCode($statusCode);
  $response-&gt;setStreamName(basename($file));
  
  $headers = new Headers();
  $headers-&gt;addHeaders(array(
      'Pragma' =&gt; 'public',
      'Expires' =&gt; $cacheExpires-&gt;format('Y/m/d H:i:s'),
      'Cache-Control' =&gt; 'no-cache',
      'Accept-Ranges' =&gt; 'bytes',
      'Content-Description' =&gt; 'File Transfer',
      'Content-Transfer-Encoding' =&gt; 'binary',
      'Content-Disposition' =&gt; 'attachment; filename="' . basename($file) .'"',
      'Content-Type' =&gt; 'audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3',  // $media-&gt;getFileType(),
      'Content-Range' =&gt; "bytes {$rangeFrom}-{$rangeTo}/{$fileSize}",
      'Content-Length' =&gt; $fileSize,
      'Etag' =&gt; $etag,
      'X-Pad' =&gt; 'avoid browser bug',
  ));
  $response-&gt;setHeaders($headers);
  return $response;
  </code></pre>
  
  <p>I have tried playing with almost every HEADER fields (even removing the ranges), but the browser always gets <code>isFinite(audio.duration) === false</code>. Everything else seems to work, including playback, flawlessly.</p>