views:

24

answers:

2

I read the following question and answer http://stackoverflow.com/questions/1995589/html5-audio-safari-live-broadcast-vs-not

Still unclear how to resolve the issue in my situation:

The audio files (mp3) I am working with are stored in mySQL and pulled into the browser by a PHP script that sends the Content-length and Content-type headers ahead of the data. This works perfectly in Firefox, Opera, Chrome, IE 6,7,8.

For some reason, though, Safari is unable to determine the file size and insists the data is a stream, both with audio and embed tags...

The suggestion in the above post has to do with a server plugin that I assume would have to do with serving the file from a file system path, not a database. How do I resolve this with my data being served from mySQL?

Thanks,

M

A: 

See this answer; altough it mentions video, it's the same thing. Basically you need to tell the client how big the file is when you send the response (which you do); to support seeking, you must also parse Range headers from the client. Maybe the problem's there, but probably there's more to it.

EDIT: Reading the answer you linked to, you definitely need to parse the Range headers: and not just the left side of the interval, as in the answer I've linked to.

Artefacto
A: 

Heh. This was easier than I thought.

I just added the following header to the PHP file that serves the audio:

header('Content-Range: bytes 0-'.$audioLength.'/'.$audioLength);

where $audioLength is the length of the file in bytes - this value is retrieved from the file an stored along with the audio data in the mySQL database. Apparently Safari doesn't mind being told that the range is the entire content length. FUnny.

So, at least in Safari ver 5.0, here is no need for any deeper involvement in Range headers than this.

Manca Weeks