Search code examples
phpinternet-explorerfirefoxstreamingmp3

Firefox/IE play streamed MP3 (Served with PHP)


I'm having trouble playing a locally created mp3 through firefox and IE, although they work fine in Chrome.

The file is basically this:

header('Content-Type: application/octet-stream');
header('X-Pad: avoid browser bug');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-type: audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3');
header('Content-Disposition: inline; filename="'.$file_name.'.mp3"');
header('Content-Length: ' . filesize('files/'.$file_name.'.mp3'));

ob_clean();
flush();

readfile('files/'.$file_name.'.mp3');

exit();

I don't get any type of error in IE, but in firefox I'm met with:

HTTP "Content-Type" of "audio/mpeg3" is not supported. Load of media resource [url here]

I tried it with just audio/mpeg as the content-type but had the same problem.


Solution

  • Firefox does not generally support MP3.

    Also, the correct content type is audio/mpeg. The others you are using are not correct.