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