Saurdo Posted April 15, 2009 Share Posted April 15, 2009 So while passing an mp3 file through php I noticed that the combination of Firefox and quicktime has quite the unusual bug. It apparently won't load all the way. It will load infinitely and only play the first couple seconds of the file. This apparently only occurs in Firefox. It works in IE8, IE7, IE6, Opera, and Chrome. I haven't tested it in different versions of Firefox though. Here's my three lines code: header("Content-type: audio/mpeg"); header("Content-Length: " . filesize("34Box.mp3")); readfile("34Box.mp3"); You can hear for yourself here: http://www.saurdo.com/test/phpmp3/test.php And before you start thinking that the mp3 is being distorted; it's supposed to sound like that. So, has anyone seen this problem before? And if so how was it fixed? Quote Link to comment Share on other sites More sharing options...
gizmola Posted April 15, 2009 Share Posted April 15, 2009 Are you using output buffering? What webserver and version are you using? How large is 34Box.mp3 in bytes? Did you check to see if the Content-Length value being sent in the header actually matches the file? Quote Link to comment Share on other sites More sharing options...
Saurdo Posted April 15, 2009 Author Share Posted April 15, 2009 Thanks for the quick reply. Those three lines are literally everything in my php file. I'm using PHP v.5.2.6 with Apache v.2.0.63 on a Linux box. It's broken on my local WAMP server as well. I just did the file size comparison and unfortunately (because that would have at least given us a lead) everything matches. Quote Link to comment Share on other sites More sharing options...
gizmola Posted April 15, 2009 Share Posted April 15, 2009 So when you say you did the file size comparison, you used some tool to check the header that is being sent, and that value matches the size? Make sure there's no empty space at the bottom of the script, before the end tag, or better yet, remove the end tag (?>) entirely from the script, and try that. Also, since you're using apache 2, how about a test where you omit the Content-Length header entirely? Quote Link to comment Share on other sites More sharing options...
Saurdo Posted April 15, 2009 Author Share Posted April 15, 2009 Yes, I used the first online tool I found on Google. Turns out the solution was much simpler. It is the difference between: header("Content-Length: " . filesize("34Box.mp3")); and header("Content-Length: " . filesize("34Box.mp3").";"); When I pasted the code into my previous post I removed the extra ."; " thinking that it was just extraneous and having no knowledge of its actual effect. Thanks for the help. Next time I'll make sure to paste my code exactly as i have it in the file. Quote Link to comment Share on other sites More sharing options...
gizmola Posted April 15, 2009 Share Posted April 15, 2009 Oh yes, hehe, the headers need that trailing semi colon. Sometimes you miss the forest for the trees. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.