I have a very similar situation to the person who asked: http://stackoverflow.com/questions/1516661/can-i-serve-mp3-files-with-php Basically I am trying to protect mp3 files from direct download, so users have to go through php to get authenticated first. Here's my code:
header('Content-type: audio/mpeg');
header('Content-length: ' . filesize($file));
header('X-Pad: avoid browser bug');
Header('Cache-Control: no-cache');
header("Content-Transfer-Encoding: binary");
header("Content-Type: audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3");
readfile($file);
Here's my problem: The file only plays a very small chunk of the beginning (via Quicktime in the browser) and then stops - Quicktime seems to think the length of the file is only as long as the chunk it managed to download. When I reload - it plays a slightly larger chunk - whatever it managed to download up to that point.
Is that a problem in the headers I am sending? How would I stream such a file? Is it a problem if an swf is reading from that file?
Thanks!
Thank you guys for all the answers. Although none of these things were exactly what solved the problem, many of them sent me in the right direction. Much appreciated. For the full solution see my answer below