与PHP程序结合的目的,在于实现通过 CuPlayerSetFile.php?id=999 这样的调用数据库id形式设置文件,来实现动态调用视频地址进行播放。

 

示例3-7-1:网页部分代码写法参考:

<script type="text/javascript" src="images/swfobject.js"></script>
<script type="text/javascript">
var so = new SWFObject("CuPlayerMiniV4.swf","ply","600","410","9","#000000");
so.addParam("allowfullscreen","true");
so.addParam("allowscriptaccess","always");
so.addParam("wmode","opaque");
so.addParam("quality","high");
so.addParam("salign","lt");
so.addVariable("CuPlayerSetFile","CuPlayerSetFile.php?FlvID=<%=FlvID%>"); //播放器配置文件地址,可以接参数
so.write("CuPlayer");
</script>


程序文件CuPlayerSetFile.php写法参考:

<?php
require_once("config.php");
@include("My89525_myfunction.php");
$FlvID=chkstr($_GET["FlvID"],2);//①. 获取第一部分中传过来的FlvID值
$conn = @mysql_connect($dbhost,$dbusername,$dbpassword) or die ("Can't connect db server");
@mysql_select_db($dbname,$conn) or die ("Can't select db");
@mysql_query("SET NAMES 'gb2312'");
//@mysql_query("SET NAMES 'utf8'");
//’②. 此处对传过来FlvID的值,进行查询
$exec="SELECT * FROM jcplayer where id ='$FlvID' ";
$result=mysql_query($exec);
④. 此处rs匹配结果
$rs=mysql_fetch_object($result);
?>
<content>
<CuPlayerWidth>600</CuPlayerWidth>
<CuPlayerHeight>410</CuPlayerHeight>
<CuPlayerAutoPlay>yes</CuPlayerAutoPlay>
<CuPlayerImage>images/start.jpg</CuPlayerImage>
<CuPlayerLogo>images/Logo.png</CuPlayerLogo>
<CuPlayerPosition>top-right</CuPlayerPosition>
<CuPlayerFile><?php echo $rs->flvurl?></CuPlayerFile>
</content>