note 49725 added to function.readfile

From: Date: Mon, 07 Feb 2005 04:55:14 +0000
Subject: note 49725 added to function.readfile
Groups: php.notes 
Request: Send a blank email to php-notes+get-84596@lists.php.net to get a copy of this message
I wrote a small routine to let visitors listen to RealAudio clips of my band. I prefer this technique as it hides the location of the music files. I call the script like this : sapra.php?tune=tunename and the script looks like : <? $fname = "ra/$tune.rm"; if (!file_exists($fname)) die("No such file : $fname"); header("Content-type: audio/x-pn-realaudio"); header("Content-Length: " . filesize($fname)); readfile($fname); ?> The script works fine, however there is a huge delay before RealPlayer starts playing. I've tried a couple of variations with different headers (Cache-Control, Content-Disposition, etc.), but the delay stays. Then, I read Bob Funk's comments and replaced the readfile() with a fopen/fread/fclose loop. Alas, the delay persists. I even put a flush() after each write to output. Anyone have any comments how I can get the same performance (or close to it) as the classic .ram file method of playing RealAudio files? Thanks ---- Manual Page -- http://www.php.net/manual/en/function.readfile.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49725 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49725&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49725&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49725&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49725&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49725&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49725&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84596) next »