Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Data Integration / July 2007



Tip: Looking for answers? Try searching our database.

Loading FLV via PHP

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pasiphilo - 25 Jul 2007 19:45 GMT
Gang,

I've been unable to find any solution - or even a solid explanation - for this
problem anywhere.

I've built a custom FLV player that needs to rely on a PHP script to serve it
FLV files in order to control access to those files.  My player uses the
FLVPlayback component.  

My actionscript makes a call like this to the PHP script:

my_player.contentPath = "resource.php?id=12345"

I've also tried...

my_player.load("resource.php?id=12345");

The resource.php code in question looks something like this:

header('Content-Type: video/x-flv');
readfile("my_video.flv");

When tested, the FLVPlayback component simply won't accept the FLV served up
to it in this way.  It WILL work if loading directly from the file system, so I
know my actionscript works.  I can load just about any other type of file into
Flash this way, including JPG and SWF.  FLV is the only format that doesn't
work.

I've added the video/x-flv MIME Type to all test servers I've tried this on,
so the server should recognize the file.

So here's the question: How can I get my PHP script to serve the FLV to my
FLVPlayback-based player?

Thanks,

J
pasiphilo - 26 Jul 2007 15:58 GMT
Solved!

The root cause was that the FLV served up by the PHP script was being sent to
Flash with a .php file extension, which the FLVPlayback component doesn't seem
to like.  The root solution, therefore, was to rename the PHP script with a
.flv exension, as outlined below.

[B]The files in the "resources/" folder:[/B]
resources/
-- .htaccess
-- test.xxx (a renamed FLV file)
-- resource.flv (a renamed PHP script)

[B]The .htaccess file:[/B]
AddType application/x-httpd-php .flv

[B]The PHP script (renamed to "resource.flv"):[/B]
$filename = "test.xxx";
header('Content-Type: video/x-flv');
header('Length: ' . filesize($filename));
header('Content-Disposition: attachment; filename="'.$filename.'"');
$fd = fopen($filename, "r");
while(!feof($fd)) {
    echo fread($fd, filesize($filename));
    flush();
    }
fclose ($fd);

[B]The salient ActionScript:[/B]
//my FLVPlayback compontent instance is named "video"
video.load("[server]/resources/resource.flv");

There may be some extraneous headers in the PHP script, but at least it works.

J
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.