Note that there are some explanatory texts on larger screens.

plurals
  1. POissues with readfile() and header()
    primarykey
    data
    text
    <p>I have an mp3 handler that I use to serve mp3s for multiple reasons. I realized there is a problem in IE, Safari, and Google Chrome when the handler is used in a remote environment. The problem is, the mp3 file plays, and then restarts after about 20 seconds. This does not happen in Opera or Firefox. There is no problems streaming the file directly so it must be the handler, however for some reason streaming did work in a local environment in all browsers. Anyway, here is my code, I think the problem is with the header() or readfile(), but if the headers are removed, the issue still occurs. Any insight into this is greatly appreciated.</p> <p><strong>PHP</strong></p> <pre><code>$path="folder/$file_id/$mp3_name"; header('Content-type: audio/mpeg'); header('Content-Length: '.filesize($path)); // provide file size header("Expires: -1"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); readfile($path); </code></pre> <p><strong>Player</strong></p> <pre><code>&lt;object width="165" height="37" id="niftyPlayer1" align=""&gt; &lt;param name="wmode" value="transparent"&gt; &lt;param name=movie value="nifty/niftyplayer.swf?file=handler.php%3FID%3DDelete 930209d6459ad1e5436ba84040cd577e&amp;as=1"&gt; &lt;param name=quality value=high&gt; &lt;param name=bgcolor value=#FFFFFF&gt; &lt;embed src="nifty/niftyplayer.swf?file=handler.php%3FID%3D930209d6459ad1e5436ba84040cd577e&amp;as=1"; quality=high bgcolor=#FFFFFF width="165" height="37" name="niftyPlayer1" align="" type="application/x-shockwave-flash" swLiveConnect="true" wmode="transparent"&gt; &lt;/embed&gt; &lt;/object&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload