Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Playing a flv through a php script using readfile function


Dear all,

I'm sorry to come to this forum again with this kind of question.
I've checked all the posts that seem to be related to this problem as well as the tutorials/help pages of this site, but I still do not understand why it does not work.

Here is the situation :
I would like to play a .flv through a php file (BroadcastScript.php), using the readfile() function.
I give through the URL to my php script the "id number" of the .flv file I want to play (for instance : BroadcastScript?id=26354), and the php script do its job to find where is the file, and so on.
Finally, something that is pretty classical and that works fine with Quicktime, FlexPaper (and open source document viewer), and other players.

But I could not make it work with JWPlayer ;-(

Here is my code :

PHP :

bc.. <?php

$file_code = $_GET["id"];

(mySQL query to find the path with the id provided, which give :)

()
$path = $array['path'];
$extension = $array['extension'];
$fileName = $array['nom_presentation'];
$dirFile = $path.$fileName.'.'.$extension;

switch($extension) {
case "flv": $ctype="application/x-shockwave-flash"; break;
case "mp4": $ctype="video/mpeg"; break;
case "wmv": $ctype="video/mpeg"; break;
case "mov": $ctype="video/quicktime"; break;
}

header("Content-type: ".$ctype);
header("Cache-Control: no-cache, no-store, max-age=0, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Expires: Mon, 20 Dec 1980 00:00:00 GMT"); // Date dans le pass
header("Pragma: no-cache");
header("Content-Transfer-Encoding: binary");
header("Content-Description: File Transfer");

@readfile($dirFile) or die("File not found.");

?>




I know that this php script works well because :
1. it works with other players
2. I have a log file at the end that says that everything is ok

Now here is my setup for JWplayer :

bc.. <script type='text/javascript' src='Medias/flv_player/swfobject.js'></script>

<div id='mediaspace'>This text will be replaced</div>

<script type='text/javascript'>
var so = new SWFObject('Medias/flv_player/player.swf','flashContent','800','600','9');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('wmode','opaque');
so.addVariable('width','800');
so.addVariable('height','600');

so.addVariable('backcolor','000000');
so.addVariable('frontcolor','999999');
so.addVariable('lightcolor','FFFFFF');
so.addVariable('controlbar','over');
so.addVariable('stretching','none');


so.addVariable('provider', 'video');
so.addVariable('file', escape("BroadcastScript.php?id=26354"));

so.write('mediaspace');
</script>



Unfortunately it does not work. Of course, I tried many things to make this work (with advices found on the former posts of this forum), but unsuccessfully.

That would be so great if you could help me.

Thank you by advance for the time you will spend on this.

Sebastien
(I repost this note because I think I did not put it initially in the right topic.

1 Community Answers

JW Player

User  
0 rated :

Please note that, thanks to Craterscore, this problem had been solved.
You can find the conversation here :

http://www.longtailvideo.com/support/forums/jw-player/setup-issues-and-embedding/12032/playing-a-flv-through-a-php-script-with-a-file-id#comment-75483

Thanks / Sebastien

This question has received the maximum number of answers.