Solved

Stream out file in PHP

Posted on 2007-03-29
1
4,342 Views
Last Modified: 2008-01-09
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.
0
Comment
Question by:OliWarner
1 Comment
 
LVL 23

Accepted Solution

by:
Zeffer earned 500 total points
ID: 18821856
so it has to Content-Type at fault..
the flv is being loaded like a swf ..
the php needs to let the player know it's a streaming flv ..like the other platforms it works on.
video/x-flv.. must be wrong..

and looking around..
this is for you..! almost at the bottom of the page//up a dozen posts..stefan has the same problem..
http://www.flashcomguru.com/index.cfm/2005/11/2/Streaming-flv-video-via-PHP-take-two

I hope this helps :)

Z
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now