播放器开灯关灯的功能,实际是利用AS与JS的交互实现的,通过flash来控制js的动作。
例(4.7)-1:开灯关灯相关的代码如下:
第1步:在网页html代码中的head部分增加:
<SCRIPT LANGUAGE=JavaScript>
<!--
function getLight(pars){if(pars=="open"){close_light(this)}else{close_light(this)}};function thisMovie(movieName){if(navigator.appName.indexOf("Microsoft")!=-1){return window[movieName]}else{return document[movieName]}}
//-->
</SCRIPT>
第2步:在网页样式表css文件中增加:
.video { OVERFLOW: hidden; WIDTH: 100%; POSITION: relative}
.close_light_bg {DISPLAY: none; BACKGROUND: #000; FILTER: alpha(opacity = 95); LEFT: 0px; WIDTH: 100%; POSITION: absolute; TOP: 0px; HEIGHT: 100%; opacity: .95}
第3步:在网页html代码中的<body>部分增加一行背景层:
<div class="close_light_bg" id="close_light_bg"></div>
第4步:播放器部分:
<script type="text/javascript" src="/player/js/swfobject.js"></script>
<div class="video" id="CuPlayer"><b>网页视频播放器加载中,请稍后...</b></div>
<script type="text/javascript">
var so = new SWFObject("/Player/player.swf","ply","520","325","9","#000000");
so.addParam("allowfullscreen","true");
so.addParam("allowscriptaccess","always");
so.addParam("wmode","opaque");
so.addParam("quality","high");
so.addParam("salign","lt");
so.addVariable("JcScpFile","/Player/CuSunV4set.xml");
so.addVariable("JcScpVideoPath","http://demo.cuplayer.com/file/test.mp4");
so.addVariable("JcScpImg","/player/Images/flashChangfa2.jpg");
so.write("CuPlayer");
</script>
第5步:在网页html代码中的播放器代码后面增加:
<script language=javascript src="/player/js/jquery-1.4.2.min.js" type=text/javascript></script>
<script language=javascript src="/player/js/action.js" type=text/javascript></script>