English 中文(简体)
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>

最佳回答

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 });

问题回答

You have some JavaScript that works.

You have some PHP that generates some JavaScript that doesn t work.

Therefore, the JavaScript you are generating doesn t match the JavaScript you know works.

Throwing some PHP down and saying "This doesn t work" is not a good approach to solving the problem.

You should be comparing the output of the PHP with the JavaScript that you know works.

(I d guess it probably has something to do with missing quote marks around a JS string)





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签