Link to home
Start Free TrialLog in
Avatar of OliWarner
OliWarner

asked on

Stream out file in PHP

I'm making an application where members can stream out videos (as FLVs) a set number of times.

I know in ASP you can stream files out as I've done it. When I try it in PHP, the entire film has to download before the Flash applet starts playing. Due to the size of the videos this is hardly ideal.

This worked when I was testing the FLV directly (not going through PHP, just HTTP GETting it off the server).

Here's the important part of my code:

<?
session_start();
ob_start();

header("Content-Type: video/x-flv");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

$fh = fopen(realpath("filename.flv"), "rb");
fseek($fh, 0);
while (!feof($fh)) {
      print (fread($fh, 500));
      ob_flush();
}
fclose($fh);
?>

Either that or the flash player cannot understand what the data means, like it can via direct download. I don't know how to tell the difference.
ASKER CERTIFIED SOLUTION
Avatar of Zeffer
Zeffer
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial