在网页中经常会用到视频播放的功能,下面介绍一下swfobject.js的视频播放应用:
html代码结构:
<div id="video_content"></div>
css样式结构:
body{background: #003368}
#video_content{width:600px;height:400px;margin:200px auto;}
js代码:
function showFLV(flvId,flvUrl,imgUrl,w,h){
var imgUrl = imgUrl;
var flvUrl = flvUrl;
var w = w || "907";
var h =h || "455";
var s1 = new SWFObject("flvplayer.swf","single",w,h,"7");
s1.addParam("allowfullscreen","true");
s1.addParam("wmode","transparent");
s1.addVariable("file",flvUrl);
s1.addVariable("image",imgUrl);
s1.addVariable("width",w);
s1.addVariable("height",h);
s1.addVariable('autostart','true');
s1.write(flvId);
}
showFLV('video_content','flv_4.flv','',600,400);
结果实现如图: