上传好文件,在后台新建一个模块,添flash地址如:
plugins/music/player.swf?mp3=/music/1.mp3|/music/2.mp3&autostart=1;bgcolor=C9E972
记得设置Flash下的高度和宽的,autostart=0的话就是不自动播放,跟际需要设置背景颜色。
还可以直接HTML模式下,写入这些代码:
<object type="application/x-shockwave-flash" height="21" width="160" data="plugins/music/player.swf?mp3=/music/1.mp3|/music/2.mp3&autostart=1&autostart=1">
<param value="plugins/music/player.swf?mp3=/music/1.mp3|/music/2.mp3&autostart=1" name="movie" />
<param value="transparent" name="wmode" /></object>
注意:<param value="transparent" name="wmode" />可以使播放器适应任何颜色背景!
<html>
<head>
<script language="javascript">
function init()
{ document.changeframe.totalfrm.value=document.wgzc.totalframes }
</script>
</head>
<body onload="init()" bgcolor="#FFFFFF" bgproperties="fixed">
<fieldset>
<legend><font color="#FF0000">控制Flash动画</font></legend>
<form name="changeframe">
<font color="#800000">
Flash动画帧数:</font><font color="#000080"><b><input name="totalfrm" type="text" size=4 value="1" disabled>
</b></font><font color="#800000">
输入第</font><b><font color="#000080"><input name="framenum" type="text" size=4 value="1"></font></b><font color="#800000">帧,再点击"指定帧"。</font>
</form>
<a href="#" onclick="javascript:document.wgzc.play()"><font color="#800080">播放</font></a>
<b><font color="#000080">
</font></b>
<a href="#" onclick="javascript:document.wgzc.stopplay()"><font color="#800080">停止</font></a>
<font color="#000080">
<b> </b></font>
<a href="#" onclick="javascript:document.wgzc.rewind()"><font color="#800080">停止返回第一帧</font></a>
<b><font color="#000080">
</font></b>
<a href="#" onclick="javascript:document.wgzc.gotoframe(document.changeframe.framenum.value)"><font color="#800080">指定帧</font></a><center>
</fieldset>
<OBJECT classid="clsidD27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0"
ID=wgzc WIDTH=500 HEIGHT=100>
<PRAM NAME=movie VALUE="wgzc.swf">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src="wgzc.swf" quality=high bgcolor=#FFFFFF
WIDTH=500 HEIGHT=100 TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</EMBED>
</OBJECT>
</center>
</body> </html>
project ---> add To project ---> components and Controls
插入Shockwave Flash Object
编译器会插入一个CShockwaveFlash类。。
在你的view类里面声明一个CShockwaveFlash成员
CShockwaveFlash m_flash;
然后映射WM_CREATE消息
int CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (!CView::OnCreate(lpCreateStruct))
return -1;
m_flash.Create(NULL, WS_CHILD | WS_VISIBLE,
CRect(0, 0, 500, 500), this, 1111);
m_flash.LoadMovie("你的swf文件绝对路径");
m_flash.Play();
return 0;
}
<style>
body,td,button{font:normal 12px Tahoma;color:#333333;text-align:center}
.drag{position:relative;cursor:hand}
button{border:1px solid #333333;background:#EEEEEE;margin:2px;font-family:Webdings;height:20px}
div{cursor:default}
#menu{margin:3;line-height:20px;border:1px solid #dedede;background:#FFFFFF;display:none;position:absolute}
#menu a:link,a:visited{border:1px solid #FFFFFF;background:#FFFFFF;text-decoration:none;display:block;padding:0 3;margin:1;color:#333333;cursor:default;text-align:left;text-indent:15px}
#menu a:hover{background:#dedede;border-color:#666666;color:#000000}
#ctlButtons IMG{behavior:url(rollover.htc)}
</style>
引用驱动程序:
<script src="play.js"></script>
以下是flash影片播放和控制界面代码:
<div oncontextmenu="return false" onselectstart="return false">
<div style="padding:0">
<table border="0" cellpadding="0" cellspacing="1" bgcolor="#000000"><tr><td>
<object id="movie" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase= "http://download.macromedia.com/pub/ shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="550" height="400" align="middle">
<param name="movie" value="about:blank" />
<param name="quality" value="high" />
</object>
</td></tr></table>
<table style="width:550px;height:35px;vertical-align:bottom" cellspacing="0" cellpadding="0" border="0">
<tr>
<td style="">
<table style="border:0px solid #333333;width:90%;" cellpadding="1" cellspacing="0">
<tr>
<td style="text-align:left;vertical-align:left;background:url(bg.gif);height:8px" onMouseDown="Jump(total*event.offsetX/421|0)">
<div id="bar" style="width:0%;font:3px;height:3px;background:#00FF44"></div>
</td>
<tr>
</table>
</td>
<td style="text-align:right;width:50px;font:11px Tahoma" id="frameCount"></td>
</tr>
</table>
<span id="ctlButtons">
<img onClick="Rewind();" title="跳至第一帧" text="9" src="images/button/dd1.gif" hoverSrc="images/button/hh1.gif">
<img onClick="Back();" title="快退" text="7" src="images/button/dd2.gif" hoverSrc="images/button/hh2.gif">
<img onClick="Play();" title="播放" text="4" src="images/button/dd3.gif" hoverSrc="images/button/hh3.gif">
<img onClick="Pause();" title="暂停" text=";" src="images/button/dd4.gif" hoverSrc="images/button/hh4.gif">
<img onClick="Stop();" title="停止" text="<" src="images/button/dd5.gif" hoverSrc="images/button/hh5.gif">
<img onClick="Forward();" title="快进" text="8" src="images/button/dd6.gif" hoverSrc="images/button/hh6.gif">
<img onClick="GoToEnd();" title="跳至最末帧" text=":" src="images/button/dd7.gif" hoverSrc="images/button/hh7.gif">
<img onClick="Replay();" title="重放" text="q" src="images/button/dd8.gif" hoverSrc="images/button/hh8.gif">
<img onClick="showMenu(menu);" title="打开 Flash 文件" text="5" src="images/button/dd9.gif" hoverSrc="images/button/hh9.gif">
<input type="file" id="moviefile" style="display:none" onpropertychange="loadMovie()"></span>
<div id="menu" onClick="this.style.display=''''''''none''''''''">
<a href="打开指定URL" onClick="OpenRemoteSwf();return false">打开指定URL</a>
<a href="选择本地文件" onClick="selectMovie();return false">选择本地文件</a>
<a href="选择本地文件" onClick="alert(''''''''Wren FLash Player 1.0 Preview\nCopyright (C) WRen.Cn'''''''');return false">关于Wren Flash Player</a>
</div></div>
运行播放器的驱动程序:
<script defer>
var movie=document.getElementById("movie");
loadSWF("http://down.wren.cn/flash/navigation_68.swf","600","400"); //loadSWF("flash地址","宽度","高度")
</script>
下面看看我写的驱动程序代码,保存为play.js:
var total;//定义flash影片总桢数
var frame_number;//定义flash影片当前桢数
//以下是滚动条图片拖动程序
var dragapproved=false;
var z,x,y
//移动函数
function move(){
if (event.button==1&&dragapproved){
y=temp1+event.clientX-x;
//以下是控制移动的范围
if(y<0)
y=0;
if(y>420)
y=420;
z.style.pixelLeft=y
movie.GotoFrame(y/420*total);//移动到某一位置,flash影片播放到某个位置
return false
}
}
//获得拖动前初始数据的函数
function drags(){
if (!document.all)
return
if (event.srcElement.className=="drag"){
dragapproved=true
z=event.srcElement
temp1=z.style.pixelLeft
x=event.clientX
document.onmousemove=move
}
}
//动态显示播放影片的当前桢/总桢数
function showcount(){
frame_number=movie.CurrentFrame();
frame_number++;
frameCount.innerText=frame_number+"/"+movie.TotalFrames;
element.style.pixelLeft=420*(frame_number/movie.TotalFrames);//滚动条图片随之到相应的位置
if(frame_number==movie.TotalFrames)
clearTimeout(tn_ID);
else
var tn_ID=setTimeout(''''''''showcount();'''''''',1000);
}
//使影片返回第一帧
function Rewind(){
if(movie.IsPlaying()){
Pause();
}
movie.Rewind();
element.style.pixelLeft=0;
frameCount.innerText="1/"+total;
}
//播放影片
function