Advertisement

03.29.2007 at 06:33PM PDT, ID: 22481951
[x]
Attachment Details

Stream out file in PHP

Asked by OliWarner in PHP Scripting Language, Macromedia Flash

Tags: php, stream, file

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.Start Free Trial
[+][-]03.29.2007 at 11:28PM PDT, ID: 18821856

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, Macromedia Flash
Tags: php, stream, file
Sign Up Now!
Solution Provided By: Zeffer
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32