Hello PHP people :)

I have a tough one here, I wrote a content script that plays media files,
but I can't seem to get things to actually buffer and stream as they should.
Here's the conundrum:

http://server/media/file.asf - Media player will buffer and start playing
before download completes
http://server/content.php?f=media/file.asf - Media player has to download
entire file before it starts trying to play

Here's the source of content.php, anyone see anything obvious that I'm
missing? I've been all over the HTTP/1.1 spec and media RFCs trying to
figure out what the heck I'm missing. Windows Media Player interprets the
media name as "content" if that's any help. Alse, the mime types are all
correct so that's not the issue, I'm just trying to figure out how to make
the players buffer+play instead of download+play.

$mime_type = strtolower(strrchr($f,'.'));
$mime_type_array = array(
        '.asf'  => 'application/vnd.ms-asf',
        '.avi'  => 'video/x-msvideo',
        '.gif'  => 'image/gif',
        '.jpg'  => 'image/jpeg',
        '.mov'  => 'video/quicktime',
        '.mpe'  => 'video/mpeg',
        '.mpeg' => 'video/mpeg',
        '.mpg'  => 'video/mpeg',
        '.ra'   => 'audio/x-pn-realaudio',
        '.ram'  => 'audio/x-pn-realaudio',
        '.rm'   => 'audio/x-pn-realaudio',
        '.wmv'  => 'audio/x-ms-wmv'

// this is our security, bleh
        header("Location: /error.php");
$filename = '/path/to/'.$f;
$dlname = substr(strrchr($filename,'/'),1);
$offset = (isset($nocache)?0:(86400 * 3));
header("Accept-Ranges: bytes");
header("Expires: ".gmdate("D, d M Y H:i:s \G\M\T", time() + $offset));
header("Cache-Control: max-age=".$offset);
header("Last-modified : ".gmdate("D, d M Y H:i:s \G\M\T",
header("Content-Length: ".filesize($filename));
header("Content-Disposition: filename=$dlname");
        header("Content-Type: ".$mime_type_array[$mime_type]);

Thanks in advance for any help,
Please cc me on any replies since I am not on this mailing list.

Stephen VanDyke

PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to