Jump to content

[SOLVED] Passing MP3 through PHP - Quicktime Firefox bug


Saurdo

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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? 

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.