I created a service class that outputs movie files to the browser and I tried clearing the output buffer before I output the file but when I do that and click another page while the movie is playing I get an error.
Here is the main code that outputs the video from my service:
ob_clean();
flush();
ob_end_flush();
// Vars
$filePath=realpath($file->getFileLocation());
$chunkSize= 1 * (1024 * 1024); // How many bytes per chunk
$buffer='';
$fileHandle=fopen($filePath, 'rb');
while (!feof($fileHandle))
{
$buffer=fread($fileHandle, $chunkSize);
echo $buffer;
//ob_flush(); flush();
}
fclose($fileHandle);
And here is the error I am getting:
Warning: Cannot modify header information - headers already sent in /usr/share/php5/prado-trunk/framework/Exceptions/TErrorHandler.php on line 168
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Internal Server Error</title>
<style type="text/css">
/*<![CDATA[*/
body {font-family:"Verdana";font-weight:normal;color:black;background-color:white;}
h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
h3 {font-family:"Verdana";font-weight:bold;font-size:11pt}
p {font-family:"Verdana";font-weight:normal;color:black;font-size:9pt;margin-top: -5px}
.version {color: gray;font-size:8pt;border-top:1px solid #aaaaaa;}
/*]]>*/
</style>
</head>
<body>
<h1>Internal Server Error</h1>
<h2>[Warning] Cannot modify header information - headers already sent (@line 420 in file /usr/share/php5/prado-trunk/framework/Web/THttpResponse.php).</h2>
<p>
An internal error occurred while the Web server was handling your request.
Please contact the <a href="mailto:me@localhostcom">webmaster</a> to report this problem.
</p>
<p>
Thank you.
</p>
<div class="version">
2008-04-25 09:34
</div>
</body>
</html>HTTP/1.1 302 Found
Date: Fri, 25 Apr 2008 16:34:24 GMT
Server: Apache/2.2.4 (Linux/SUSE)
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location:
http://mysite/index.htm/page,Revisions.PreviewFile/file,202Content-Length: 0
Keep-Alive: timeout=15, max=96
Connection: Keep-Alive
Content-Type: text/html
I noticed that THttpResponse is doing some output buffering stuff by the error I am getting above by why does that break and show the error above when I try clicking on a link while a page is playing a movie that I am sending from my application?
Thanks.