Search code examples
phpjavascriptflv

Javascript & Ajax video player not working in PHP file


PHP + javascript code + flv player:

I am trying to play a .flv video on a web page and I have the file name to play from mysql database so i need to use PHP. In the code below there is a script that runs a video player (favideo from Adobe).

This video player work fine when the web page have the .html extension and it won't work with .php one, resulting my php code not working.

thanks in advance.

here is the code:

    <HTML>
<head>
<title> PropertyVideo
</title>
    <script src="AC_RunActiveContent.js" type="text/javascript"></script>
    <script src="FAVideo.js" type="text/javascript"></script>
</head>
<body onLoad="">
<?php
    include '../Header.php';
    require '../../DataLayer/property_video.php';
    //$id=$_GET['pro_id'];
    $id=1;
    $vid=new property_video();
    $vids=$vid->GetRecords("property_id=".$id);
    $vid=$vids[0];
    $path = $vid->path;
?>
<div id="divOne"></div>
    <script type="text/javascript">
        playerOne = new FAVideo("divOne", <?PHP echo $path ?>,0,0,{ autoLoad:true, autoPlay:true });
    </script>
    <script>
        playerOne.addEventListener("playheadUpdate",this,myHandler);

        playerOne.removeEventListener("playheadUpdate",this,myHandler);

        function myHandler() 
        {
            //alert("eh");
        }
    </script>

<?php
    include 'footer.php';
?>
</body>
</HTML>

and the actual generated html code is:

<HTML>

PropertyVideo WelCome6 playerOne = new FAVideo("divOne", demo_video.flv,0,0,{ autoLoad:true, autoPlay:true });

<script>
    playerOne.addEventListener("playheadUpdate",this,myHandler);

    playerOne.removeEventListener("playheadUpdate",this,myHandler);

    function myHandler() 
    {
        //alert("eh");
    }
</script>


Solution

  • There might be more errors, but you certainly need to add some quotes to the path:

    playerOne = new FAVideo("divOne", "<?PHP echo $path ?>",0,0,{ autoLoad:true, autoPlay:true });